note 76455 deleted from function.array-slice by cmb
| From: | cmb@php.net | Date: | Sun, 29 Dec 2019 12:28:47 +0000 |
| Subject: | note 76455 deleted from function.array-slice by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213701@lists.php.net to get a copy of this message | ||
Note Submitter: phpnotasp at gmail dot com
----
It should be noted that this function does NOT modify the original array. So if you need to
array_pop() or array_shift() without modifying the original array, you can use array_slice().
<?php
$input = array('a', 'b', 'c');
$output = array_slice($input, 1);
print_r($output);
print_r($input);
/*
Array
(
[0] => b
[1] => c
)
Array
(
[0] => a
[1] => b
[2] => c
)
*/
?>