note 115717 added to function.array-slice
| From: | robert dot johnson at icap dot com | Date: | Fri, 12 Sep 2014 09:58:20 +0000 |
| Subject: | note 115717 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200428@lists.php.net to get a copy of this message | ||
array_slice() seems to work on associative arrays and preserves the keys. I just ran this test on
PHP 5.5:
<?php
$test = array(
'a'=>'hello 1',
'r'=>'hello 2',
'h'=>'hello 3',
'w'=>'hello 4',
't'=>'hello 5',
'n'=>'hello 6',
'k'=>'hello 7',
'b'=>'hello 8');
print_r( array_slice($test,2,5) );
?>
Output:
Array
(
[h] => hello 3
[w] => hello 4
[t] => hello 5
[n] => hello 6
[k] => hello 7
)
----
Server IP: 87.117.229.81
Probable Submitter: 80.254.158.164 (proxied: 193.130.196.1)
----
Manual Page -- http://php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/115717
Del: integrated -- https://master.php.net/note/delete/115717/integrated
Del: useless -- https://master.php.net/note/delete/115717/useless
Del: bad code -- https://master.php.net/note/delete/115717/bad+code
Del: spam -- https://master.php.net/note/delete/115717/spam
Del: non-english -- https://master.php.net/note/delete/115717/non-english
Del: in docs -- https://master.php.net/note/delete/115717/in+docs
Del: other reasons-- https://master.php.net/note/delete/115717
Reject -- https://master.php.net/note/reject/115717
Search -- https://master.php.net/manage/user-notes.php