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"); } } print("$content_array[0]\n");
//end As I stated. The match happens and the "Matched on..." message happens, but the print statement outside the "while" loop does not. Its php-4.2.2 running on RedHat 8.0 (don't go there.) Its the stock redhat php package. I don't trust redhat libraries for building php from scratch. Of course, this might actually be the problem, too. :-) Curtis On Tue, 25 Nov 2003, Marek Kilimajer wrote: > Curtis Maurand wrote: > > Hello, > > consider the following code (content.txt is tab delimited). > > > > $city = "Ipswitch"; > > $content = fopen("content.txt", "r"); > > $city_found = 0; > > while (!feof($content) && $city_found == 0) > > { > > $my_line = fgets($content, "r"); > > $content_array = explode("\t",$my_line); > > if ($content_array == $city) > This will never be equal, $content_array is an array, $city is a string > > > { > > print("Matched on $content_array[0]"); > > $city_found = 1; > > } > > } > > print("$content_array[0]<br>\n"); > > > > Here's the trouble. > > > > inside the while loop $content_array is available to me. > > outside the loop $content_array is not available. What > > am I doing wrong? > > The file might end with an empty line, in that case $my_line in the last > iteration contains only the newline character. > -- -- Curtis Maurand mailto:[EMAIL PROTECTED] http://www.maurand.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php