>$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");
I think what you got is a scope problem. You are creating $content_array
in your while loop so its scope is limited to the while loop. To test this
simply do a var_dump or print_r on $content_array outside your loop and
see if it actually is an array, which I guess it won't it will either be
null or an empty string.
To solve simply do an initialisation of the variable before the while loop
like $content_array = ''.
Regards
Stefan