note 117945 added to function.array-merge
| From: | info at eastghost dot com | Date: | Sat, 05 Sep 2015 01:37:23 +0000 |
| Subject: | note 117945 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203705@lists.php.net to get a copy of this message | ||
We noticed array_merge is relatively slower than manually extending an array:
given:
$arr_one[ 'x' => 1, 'y' => 2 ];
$arr_two[ 'a' => 10, 'b' => 20 ];
the statement:
$arr_three = array_merge( $arr_one, $arr_two );
is routinely 200usec slower than:
$arr_three = $arr_one;
foreach( $arr_two as $k => $v ) { $arr_three[ $k ] = $v; }
200usec didn't matter...until we started combining huge arrays.
PHP 5.6.x
----
Server IP: 72.52.91.14
Probable Submitter: 74.96.181.211
----
Manual Page -- http://php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/117945
Del: integrated -- https://master.php.net/note/delete/117945/integrated
Del: useless -- https://master.php.net/note/delete/117945/useless
Del: bad code -- https://master.php.net/note/delete/117945/bad+code
Del: spam -- https://master.php.net/note/delete/117945/spam
Del: non-english -- https://master.php.net/note/delete/117945/non-english
Del: in docs -- https://master.php.net/note/delete/117945/in+docs
Del: other reasons-- https://master.php.net/note/delete/117945
Reject -- https://master.php.net/note/reject/117945
Search -- https://master.php.net/manage/user-notes.php