1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00
Files
archived-php-src/ext/standard/tests/strings/bug71969.phpt
Nikita Popov e8678fcb42 Fixed bug #75902
Don't special-case nested arrays/objects in str_replace(), instead
perform a string cast on them as well. For arrays, this will always
result in the usual conversion warning.

This behavior is consistent with preg_replace(). If we didn't want
to cast the array to string here, we should instead perform the
replacement recursively. Silently copying it is just confusing.
2020-03-10 16:49:17 +01:00

22 lines
441 B
PHP

--TEST--
Bug #71969 (str_replace returns an incorrect resulting array after a foreach by reference)
--FILE--
<?php
$a = array(
array("one" => array("a"=>"0000", "b"=>"1111")),
);
//foreach by reference, changing the array value
foreach($a as &$record)
{
$record["one"]["a"] = "2222";
}
var_dump(str_replace("2", "3", $a));
?>
--EXPECTF--
Warning: Array to string conversion in %s on line %d
array(1) {
[0]=>
string(5) "Array"
}