Bug #14097 Updated: Add option to file() to strip \n

From: Date: Mon, 19 Nov 2001 01:00:55 +0000
Subject: Bug #14097 Updated: Add option to file() to strip \n
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-70853@lists.php.net to get a copy of this message
ID: 14097 Updated by: sniper Reported By: deelee@fundy.net Old Summary: newlines in file function Old Status: Bogus Status: Analyzed Old Bug Type: Filesystem function related Bug Type: Feature/Change Request Operating System: Linux PHP Version: 4.0.6 Previous Comments: ------------------------------------------------------------------------ [2001-11-17 22:49:13] sniper@php.net This is by design. Even the manual page for file() says it. :) (Or was this a feature/change request to strip them?) ------------------------------------------------------------------------ [2001-11-17 21:52:19] deelee@fundy.net Using the file function, newlines (\n) are included in the read. The causes odd behaviour in other functions such as: mail - If the subject parameter is loaded using the file function, the newline causes the headers sent using mail to be invalid. In the case of Eudora the header information is dispalyed in the message and the From field displays the server account that generated the message - in my case "WWW User". array_search - All efforts to use this function fail with an array created with the file function. Only through the following cose will it produce the results expected: $someArray = str_replace (array("\r", "\n"), '', $someArray); (Thanks to Zak Greant for this code :) in_array - Much like array_search, the results are misleading due to the presence of newlines. A match is never found even though an echo of the array being tested looks identical to the target string/integer. ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=14097&edit=1

« previous php.dev (#70853) next »