note 77743 deleted from function.array-unique by cmb

From: Date: Mon, 12 Nov 2018 14:46:14 +0000
Subject: note 77743 deleted from function.array-unique by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-209679@lists.php.net to get a copy of this message
Note Submitter: xjazey at hotmail dot com ---- This is a fast solution to remove duplicate values from an array when it contains only strings or only integers: <?php $array = array( 0 => 'Yellow', 1 => 'Green', 2 => 'Yellow', 3 => 'Blue', 4 => 'Yellow', ); $uniq = array_keys(array_flip($array)); var_export($uniq); /* Output: array ( 0 => 'Yellow', 1 => 'Green', 2 => 'Blue', ) */ ?>

« previous php.notes (#209679) next »