note 37833 added to function.fgets

From: Date: Fri, 28 Nov 2003 20:55:33 +0000
Subject: note 37833 added to function.fgets
Groups: php.notes 
Request: Send a blank email to php-notes+get-61095@lists.php.net to get a copy of this message
I had problems with EOL on Macintosh : reading a file with pairs (login:passwd) my program, running fine with only one line, don' run with a second : the second login is recognized, but not the first... due to the 'EOL' character included in the $out by : while (!feof($file)) { $line = fgets($file); $ordre++; echo $line."/"; if (eregi($user.":(.*)", $line, $out)) { $passwd = $out[1]; $num_user=$ordre; echo $passwd."/"; break;} } /* fin lecture fichier */ And unfortunately i can *NOT* act on php_ini on the server, and i try to publish my script.. So the solution i found is to put explicitely the 'EOL' in the regex : ... if (eregi($user.":(.*)\n", $line, $out)) ... and it's work Hope that Help PAUL ---- Manual Page -- http://www.php.net/manual/en/function.fgets.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37833 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37833&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37833&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61095) next »