note 104042 deleted from function.array-splice by danbrown
| From: | danbrown@php.net | Date: | Thu, 19 May 2011 13:51:40 +0000 |
| Subject: | note 104042 deleted from function.array-splice by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179878@lists.php.net to get a copy of this message | ||
Note Submitter: ollyatstithians
----
doug at badblue dot com:
That is not unexpected behaviour, it is as the documentation says:
"Returns the array consisting of the extracted elements."
In your example, $aIn is the array that gets truncated, $aOut is an array of the elements that were
removed. As the offset is more than the size of the array, no elements were removed and so an empty
array was returned.
This should make it clearer:
<?php
$array = array('Apple', 'Pear', 'Cherry');
$return = array_splice($array, 2);
var_dump($array); // array('Apple', 'Pear');
var_dump($return); // array('Cherry');
?>