mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

The check that was supposed to check whether the array slot was UNDEF was wrong and never triggered. This resulted in a replacement with the empty string or the wrong string instead of the correct one. The correct check pattern can be observed higher up in the function's code. Closes GH-10323 Signed-off-by: George Peter Banyard <girgias@php.net>
27 lines
461 B
PHP
27 lines
461 B
PHP
--TEST--
|
|
substr_replace() function - array with unset
|
|
--FILE--
|
|
<?php
|
|
|
|
$replacement = ['A', 'C', 'B'];
|
|
unset($replacement[1]);
|
|
$newarr = substr_replace(['1 string', '2 string'], $replacement, 0);
|
|
print_r($newarr);
|
|
|
|
$replacement = ['foo', 42 => 'bar', 'baz'];
|
|
unset($replacement[42]);
|
|
$newarr = substr_replace(['1 string', '2 string'], $replacement, 0);
|
|
print_r($newarr);
|
|
|
|
?>
|
|
--EXPECT--
|
|
Array
|
|
(
|
|
[0] => A
|
|
[1] => B
|
|
)
|
|
Array
|
|
(
|
|
[0] => foo
|
|
[1] => baz
|
|
)
|