|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-01 00:08 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 20:00:01 2025 UTC |
Description: ------------ When I use str_replace on an associative array to replace '<br>' with "\n" I find that values that were null have been replaced with empty strings. This affects subsequent processing as an empty string is not the same as null. Reproduce code: --------------- $pattern[] = "<br>"; $pattern[] = "<br/>"; $pattern[] = "<br />"; $replacement = "\n"; $array = array('field1' => '<br>', 'field2' => '', 'field3' => null) $array = str_replace($pattern, $replacement, $array); Expected result: ---------------- Null values should be left as null values, and not replaced with empty strings. Actual result: -------------- Values in the array that were null are being replaced with empty strings.