note 41896 added to function.array-flip
| From: | carolus at lair dot pl | Date: | Sun, 25 Apr 2004 09:14:27 +0000 |
| Subject: | note 41896 added to function.array-flip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68762@lists.php.net to get a copy of this message | ||
An easy way to check if array contains duplicated values:
if ($myArray != array_flip(array_flip($myArray)))
// $myArray contains duplicated values
else
// each value in $myArray is unique
To remove duplicates do simply:
$myArray = array_flip(array_flip($myArray));
Good Luck.
----
Manual Page -- http://www.php.net/manual/en/function.array-flip.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41896
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41896&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41896&report=yes
Search -- http://master.php.net/manage/user-notes.php