From: tony at marston-home dot demon dot co dot uk
Operating system: Windows XP
PHP version: 5.0.4
PHP Bug Type: PCRE related
Bug description: str_replace replaces nulls with empty strings
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 bug report at http://bugs.php.net/?id=33530&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33530&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33530&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33530&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33530&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33530&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33530&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33530&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33530&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33530&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33530&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33530&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33530&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33530&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33530&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33530&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33530&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33530&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33530&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33530&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33530&r=mysqlcfg