note 85193 added to function.stream-get-line

From: Date: Tue, 19 Aug 2008 17:34:56 +0000
Subject: note 85193 added to function.stream-get-line
Groups: php.notes 
Request: Send a blank email to php-notes+get-143638@lists.php.net to get a copy of this message
If the "ending" is a string, there are cases where the function doesn't return the correct value for the first time it is called. Don't be shocked if you find it returning a string value of upto "length" that includes the "ending". (See bug #44607) If the "ending" is just a single character, the function would always work correctly. ("\n" is a single character) Temporarily, until this is fixed, the below function can be used: function istream_get_line(&$fp, $length, $end) { $current = ftell($fp); $str = fread($fp, $length); $i = strpos($str, $end); if ($i === FALSE) { return $str; } else { fseek($fp, $current + $i + strlen($end)); return substr($str, 0, $i); } } ---- Server IP: 59.162.86.33 Probable Submitter: 203.123.174.105 ---- Manual Page -- http://www.php.net/manual/en/function.stream-get-line.php Edit -- https://master.php.net/note/edit/85193 Del: integrated -- https://master.php.net/note/delete/85193/integrated Del: useless -- https://master.php.net/note/delete/85193/useless Del: bad code -- https://master.php.net/note/delete/85193/bad+code Del: spam -- https://master.php.net/note/delete/85193/spam Del: non-english -- https://master.php.net/note/delete/85193/non-english Del: in docs -- https://master.php.net/note/delete/85193/in+docs Del: other reasons-- https://master.php.net/note/delete/85193 Reject -- https://master.php.net/note/reject/85193 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143638) next »