#49228 [Com]: fgets returns 2 lines

From: Date: Wed, 12 Aug 2009 02:31:50 +0000
Subject: #49228 [Com]: fgets returns 2 lines
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-140941@lists.php.net to get a copy of this message
ID: 49228 Comment by: admin at kthxbai2u dot com Reported By: admin at kthxbai2u dot com Status: Open Bug Type: Unknown/Other Function Operating System: Linux PHP Version: 5.3.0 New Comment: I was looking at fread() just now, but it requires a length... I dont want to specify a length. I am looking for the equivalent of readLn() from some other language i know (forget which one) where it reads the entire line, and only outputs that one line... Meaning there is no new line after the line I requested... Previous Comments: ------------------------------------------------------------------------ [2009-08-12 02:19:51] admin at kthxbai2u dot com Description: ------------ When I use fgets() it returns the line, and the next one... Correct me if I am wrong, but when you ask for one line, it should return one line? There is not even a function (that I have found yet) that returns ONLY 1 line... fgets should not be adding a /r/n at the end, that should be up to the programmer... Reproduce code: --------------- --- From manual page: function.fgetss --- $fp = fopen("AD_SYSTEM/popup.ads",'r'); while($line=fgets($fp)) { //add the link text to the array $ads[] = $line; } fclose($fp); echo $ads[1]; Expected result: ---------------- "http://somepopup.url/advertisement.html" (without quotes) Actual result: -------------- "http://somepopup.url/advertisement.html " (without quotes, notice the 2nd line) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49228&edit=1

« previous php.bugs (#140941) next »