Curtis Maurand wrote:
OK. That worked, thanks.

Is it me, or is that rather odd behavior?
It is you ;)

Shouldn't array elements set within a loop be available to me outside the loop if the loop exits normally? A loop is not a function (well it is, sort of.) Should I declare the variable as global?
You are in a loop, so the variable is overwriten by new value in each iteration.


global $content_array; $city_found = 1; while(!feof ...

When I was taking programming courses in college, I was taught that breaking out of a loop like that was bad practice; that it was better to leave a loop normally.
Depends. You could write

$continue=true;
while($continue && .. other conditions .. ) {
        if(... another condition ...) {
                ....
                $continue = false;
        }
}

I don't think this is any better then breaking out, and is certainly slower. break and continue constructs are here for a reason and the use is right here.

I've never programmed in "C" other than to write a crude little "dos2unix" (actually mac2dos) utility. Mosty i've written Perl, PHP Pascal and Basic. Pascal, Perl and Basic don't exhibit this behavior.
All have this behavior.

I never worked with arrays in "C." Am I wrong?


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to