note 37109 modified in function.array-merge by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 13:58:49 +0000 |
| Subject: | note 37109 modified in function.array-merge by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79871@lists.php.net to get a copy of this message | ||
While searching for a function that would renumber the keys in a array, I found out that
array_merge() does this if the second parameter is null:
Starting with array $a like:
<?php
Array
(
[5] => 5
[4] => 4
[2] => 2
[9] => 9
)
?>
Then use array_merge() like this:
<?php
$a = array_merge($a, null);
?>
Now the $a array has bee renumbered, but maintaining the order:
<?php
Array
(
[0] => 5
[1] => 4
[2] => 2
[3] => 9
)
?>
Hope this helps someone :-)
--was--
While searching for a function that would renumber the keys in a array, I found out that
array_merge() does this if the second parameter is null:
Starting with array $a like:
Array
(
[5] => 5
[4] => 4
[2] => 2
[9] => 9
)
Then use array_merge() like this:
$a = array_merge($a, null);
Now the $a array has bee renumbered, but maintaining the order:
Array
(
[0] => 5
[1] => 4
[2] => 2
[3] => 9
)
Hope this helps someone :-)
http://php.net/manual/en/function.array-merge.php