note 38853 deleted from function.feof by nlopess

From: Date: Fri, 09 Jan 2004 14:18:27 +0000
Subject: note 38853 deleted from function.feof by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-63197@lists.php.net to get a copy of this message
Note Submitter: manaskmukherjee@frontiersoft.net ---- We use feof many ways. Here I used a small text file as a data source and wanted to see a match. Text File James Bond Timothy Hunt Jose McDonald Barbe Fisher Manas Mukherjee HTML Client <html> <head> <title>name_search.html</title> </head> <body> <form method="POST" action="name_search.php"> <p><input type="text" name="agents_name" size="20"> <br><input type="submit" value="Submit" name="B1"> <input type="reset" value="Reset" name="B2"></p> </form> </body> </html> Server <?php # name_search.php $read=($agents_name); $count =0; if (!$file_open = fopen("myphptxt/agents.txt","r")) { echo "oops! I did not find this file"; } else { while(!feof($file_open)) { $count++; $line = fgets($file_open, 255); $line=(trim($line)); if ( $line == $read ){ echo "Rated $count ! $line<BR>"; $match=$line;} } if (@$match ==""){ echo "Sorry No Match";} fclose($file_open); } ?> Results: When data Matched : Rated 1 ! James Bond or Rated 5 ! Manas Mukherjee When did not match : Sorry No Match email :manaskmukherje@frontiersoft.net

« previous php.notes (#63197) next »