ID: 49228 User updated by: admin at kthxbai2u dot com Reported By: admin at kthxbai2u dot com Status: Bogus Bug Type: Unknown/Other Function Operating System: Linux PHP Version: 5.3.0 New Comment:
You can use trim with no args and it cuts the newline out? See I was used to the newline not being there... And no one has mentioned that method anywhere... I googled for that for hours on end and there are always people asking that but no solutions... Thanks, now I can resume that part of my work! <3 PHP Previous Comments: ------------------------------------------------------------------------ [2009-08-12 02:36:26] ras...@php.net 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. ------------------------------------------------------------------------ [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