note 120099 deleted from function.array-intersect by cmb

From: Date: Sun, 09 Feb 2020 08:26:05 +0000
Subject: note 120099 deleted from function.array-intersect by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-214061@lists.php.net to get a copy of this message
Note Submitter: turabgarip at gmail dot com ---- The reason that this function is considerably slow; is because it's comparing not only the values cross wise; but it also compares the array's own elements too. For example you have two arrays like; <?php $arr1 = array('green', 'blue', 'black'); $arr2 = array('yellow', 'red', 'cyan'); array_intersect($arr1, $arr2); ?> Intersection will start to compare from the first three colors like; "blue" to "green", "black" to "blue"; that are, the elements of the first array only, and yes, comparison order is arbitrary, but always in the same order. It will do the same for the second array too.

« previous php.notes (#214061) next »