note 21012 modified in function.array-slice by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:49:31 +0000 |
| Subject: | note 21012 modified in function.array-slice by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79805@lists.php.net to get a copy of this message | ||
array_slice() can be used to "re-index" an array to start from key 0. For example, unpack
creates an array with keys starting from 1;
<?php
var_dump(unpack("C*","AB"));
?>
produces
<?php
array(2) {
[1]=>
int(65)
[2]=>
int(66)
}
?>
and
<?php
var_dump(array_slice(unpack("C*","AB"),0));
?>
give you
<?php
array(2) {
[0]=>
int(65)
[1]=>
int(66)
}
?>
--was--
array_slice() can be used to "re-index" an array to start from key 0. For example, unpack
creates an array with keys starting from 1;
var_dump(unpack("C*","AB"));
produces
array(2) {
[1]=>
int(65)
[2]=>
int(66)
}
and
var_dump(array_slice(unpack("C*","AB"),0));
give you
array(2) {
[0]=>
int(65)
[1]=>
int(66)
}
http://php.net/manual/en/function.array-slice.php