note 38853 added to function.feof

From: Date: Fri, 09 Jan 2004 00:47:10 +0000
Subject: note 38853 added to function.feof
Groups: php.notes 
Request: Send a blank email to php-notes+get-63180@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.feof.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38853 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38853&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38853&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63180) next »