note 37109 deleted from function.array-merge by cmb
| From: | cmb@php.net | Date: | Mon, 19 Nov 2018 17:02:12 +0000 |
| Subject: | note 37109 deleted from function.array-merge by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-209727@lists.php.net to get a copy of this message | ||
Note Submitter: rcarvalhoREMOVECAPS at clix dot pt
----
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 :-)