note 104042 added to function.array-splice
| From: | ollyatstithians at osu1 dot php dot net | Date: | Thu, 19 May 2011 08:50:58 +0000 |
| Subject: | note 104042 added to function.array-splice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179869@lists.php.net to get a copy of this message | ||
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');
?>
----
Server IP: 109.169.40.147
Probable Submitter: 81.149.174.43
----
Manual Page -- http://www.php.net/manual/en/function.array-splice.php
Edit -- https://master.php.net/note/edit/104042
Del: integrated -- https://master.php.net/note/delete/104042/integrated
Del: useless -- https://master.php.net/note/delete/104042/useless
Del: bad code -- https://master.php.net/note/delete/104042/bad+code
Del: spam -- https://master.php.net/note/delete/104042/spam
Del: non-english -- https://master.php.net/note/delete/104042/non-english
Del: in docs -- https://master.php.net/note/delete/104042/in+docs
Del: other reasons-- https://master.php.net/note/delete/104042
Reject -- https://master.php.net/note/reject/104042
Search -- https://master.php.net/manage/user-notes.php