Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
In that case, you don't exit the parsing of the file when you look for your line, and you keep the greatest value in a variable.
But why do you bother with a text file?
For what I see, a database would be way more suited.
PHP Code:
$h=fopen("file.txt",r); $run=true; $max=0; while( (false!=$buffer=fgets($h)) && ($run==true) ){ $ary=explode("|",$buffer); //... Test your condition here against $ary if($ary[0]=='1237'){ echo "found it! ->{$ary[2]}\n"; //To stop the file parsing //$run=false; } else{ echo "not found...\n"; } if($max<$ary[0]){ //$max will hold the biggest value from your file after that. $max=$ary[0]; } } fclose($h);
__________________
Only a biker knows why a dog sticks his head out the window.
Last edited by tripy; 11-18-2007 at 07:38 PM..
|