ID:               33530
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tony at marston-home dot demon dot co dot uk
-Status:           Open
+Status:           Bogus
-Bug Type:         PCRE related
+Bug Type:         Strings related
 Operating System: Windows XP
 PHP Version:      5.0.4
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

str_replace() operates on strings and returns array of strings.
of course, NULL, false and others get converted to "" even before
str_replace() begin to work with them.


Previous Comments:
------------------------------------------------------------------------

[2005-06-30 23:55:16] tony at marston-home dot demon dot co dot uk

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.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33530&edit=1

Reply via email to