ID: 38463 Updated by: [EMAIL PROTECTED] Reported By: IFokkema at Ileos dot nl -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: All PHP Version: Irrelevant New Comment:
This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2006-08-15 08:29:43] IFokkema at Ileos dot nl Description: ------------ Hi guys, After a discussion in the list, I've reread the manual page (http://www.php.net/str_replace) and the comments, checked Google, but need some confirmation. When using an array as the search argument in str_replace(), the array is processed first to last. As expected, but this behaviour is not documented and therefor not reliable for my project. $s = "Input\r\nMore input\rSome more\nEtc"; echo str_replace(array("\r\n", "\n", "\r"), '<BR>', $s); This works as expected (putting exactly one <BR> between every line of input). Related comment on the manual page is from "jr at adslate dot com (03-Jun-2004 02:52)". But since it's not documented, I can't rely on this. If the order of replacement is ever switched, my code stops working properly. Now I have to do this, to process all OS specific line breaks correctly: $s = str_replace("\r\n", "\n", $s); $s = str_replace("\r", "\n", $s); echo str_replace("\n", '<BR>', $s); Can you guys please document the order of handling the search array? Thanks a bunch for all of your work. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38463&edit=1