note 72556 deleted from function.array-merge by cmb
| From: | cmb@php.net | Date: | Sun, 29 Sep 2019 07:32:32 +0000 |
| Subject: | note 72556 deleted from function.array-merge by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212400@lists.php.net to get a copy of this message | ||
Note Submitter: ahigerd at stratitec dot com
----
An earlier comment mentioned that array_splice is faster than array_merge for inserting values. This
may be the case, but if your goal is instead to reindex a numeric array, array_values() is the
function of choice. Performing the following functions in a 100,000-iteration loop gave me the
following times: ($b is a 3-element array)
array_splice($b, count($b)) => 0.410652
$b = array_splice($b, 0) => 0.272513
array_splice($b, 3) => 0.26529
$b = array_merge($b) => 0.233582
$b = array_values($b) => 0.151298