note 72556 added to function.array-merge
| From: | ahigerd at stratitec dot com | Date: | Wed, 24 Jan 2007 14:06:21 +0000 |
| Subject: | note 72556 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122135@lists.php.net to get a copy of this message | ||
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
----
Server IP: 69.147.83.197
Probable Submitter: 75.19.79.5
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/72556
Del: integrated -- https://master.php.net/note/delete/72556/integrated
Del: useless -- https://master.php.net/note/delete/72556/useless
Del: bad code -- https://master.php.net/note/delete/72556/bad+code
Del: spam -- https://master.php.net/note/delete/72556/spam
Del: non-english -- https://master.php.net/note/delete/72556/non-english
Del: in docs -- https://master.php.net/note/delete/72556/in+docs
Del: other reasons-- https://master.php.net/note/delete/72556
Reject -- https://master.php.net/note/reject/72556
Search -- https://master.php.net/manage/user-notes.php