Re: array problems

From: Date: Fri, 28 Nov 2003 10:55:01 +0000
Subject: Re: array problems
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-171259@lists.php.net to get a copy of this message
On Thu, Nov 27, 2003 at 08:19:02PM -0500, Curtis Maurand wrote: : On Wednesday 26 November 2003 21:53, Marek Kilimajer mumble: : > Curtis Maurand wrote: : > > Sorry, its a typo. it should be: : > > : > > $city = "Ipswitch"; : > > $city_found = 0; : > > $contentfile = fopen("content.txt", "r"); : > > while (!feof($contentfile) && $city_found == 0); : > > { : > > $my_line = fgets($contentfile, 16384); : > > $content_array = explode("\t",$my_line); : > > if ($content_array[0] == $city) : > > { : > > $city_found = 1; : > > print("Matched on $content_aray[0]<br>\n"); : > : > /* Break out of the while loop */ : > break; : > : > > } : > > } : > > print("$content_array[0]\n"); : > > : > > //end : : Is it me, or is that rather odd behavior? Shouldn't array elements : set within a loop be available to me outside the loop if the loop : exits normally? It should. However, you must be sure to take the right action if the loop exists "unnormally".

« previous php.general (#171259) next »