note 117945 deleted from function.array-merge by salathe

From: Date: Mon, 06 Sep 2021 22:44:27 +0000
Subject: note 117945 deleted from function.array-merge by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-216889@lists.php.net to get a copy of this message
Note Submitter: info at eastghost dot com ---- 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

« previous php.notes (#216889) next »