note 81484 deleted from function.array-flip by danbrown

From: Date: Fri, 14 May 2010 15:03:24 +0000
Subject: note 81484 deleted from function.array-flip by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169246@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- True, array_unique does preserve keys, but if you are incrementing in a loop, then it will stop once the key values break numerical order. If you don't care about preserving keys, a life-saver (originally a headache) for me was... <?php $new_array = array_keys(array_flip($old_array)); ?> i used this little snip-it after results from preg_match_all() as a way to remove duplicates from an array and then re-organize the numerical keys ;) *Only works on arrays with numerical keys.

« previous php.notes (#169246) next »