note 80226 rejected from function.array-splice by felipe
| From: | felipe@php.net | Date: | Sat, 05 Jan 2008 02:03:45 +0000 |
| Subject: | note 80226 rejected from function.array-splice by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134808@lists.php.net to get a copy of this message | ||
Note Submitter: Ron Cemer
----
Just a heads-up: there's a big gotcha with array_splice() when trying to insert elements into
an array without deleting any elements (in other words, when the $length parameter is zero).
Tested on PHP 5.2.4, the last example from "Example#1 array_splice() examples" (above)
FAILS.
Instead of returning array("red", "green", "blue", "purple",
"yellow"), instead it returns an empty array.
Not sure if this is a bug, or the expected behavior has changed.
$input = array("red", "green", "blue", "yellow");
array_splice($input, 3, 0, "purple");
Returns an empty array.