ID: 49228 Updated by: ras...@php.net Reported By: admin at kthxbai2u dot com -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Linux PHP Version: 5.3.0 New Comment:
As per the docs, fgets() returns the newline character that it reads. That doesn't mean there are 2 lines. It is a single line terminated by a newline character. If you don't want that newline character, trim() it off. Previous Comments: ------------------------------------------------------------------------ [2009-08-12 02:31:49] admin at kthxbai2u dot com 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... ------------------------------------------------------------------------ [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