note 70786 deleted from function.array-unique by crell

From: Date: Tue, 12 Apr 2022 00:54:11 +0000
Subject: note 70786 deleted from function.array-unique by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218169@lists.php.net to get a copy of this message
Note Submitter: Ome_Henk ---- For people looking at the flip flip method for getting unique values in a simple array. This is the absolute fastest method: <?php $unique = array_keys(array_flip($array)); ?> It's marginally faster as: <?php $unique = array_merge(array_flip(array_flip($array))); ?> And it's marginally slower as: <?php $unique array_flip(array_flip($array)); // leaves gaps ?> It's still about twice as fast or fast as array_unique. This tested on several different machines with 100000 random arrays. All machines used a version of PHP5.

« previous php.notes (#218169) next »