I want to search for a row in a text file where a word is.. for example if i want to find out which row that contains the word "Apple":
0|Orange|Orange 1|Banana|Yellow 2|Apple|Red 3|Cherry|Red
how do i do it?
Try this...
<? $file = 'somefile.txt'; $search_word = 'someword'; $arr_file = file( $file ); for( $i = 0; $i < count( $arr_file ); $i++ ) { if( strstr( $arr_file[$i], $search_word ) ) echo 'The word was found on line ' . ( $i + 1 ) . '<br>'; } ?>