note 56471 added to function.array-flip
| From: | php-general at lists dot php dot net | Date: | Sat, 03 Sep 2005 22:43:38 +0000 |
| Subject: | note 56471 added to function.array-flip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94703@lists.php.net to get a copy of this message | ||
you should not use the solution posted by t0russ at gmail dot com tp remove duplicates from an
array.
PHP does this itself in a very faster way with the nativ function array_unique()!
<?PHP
$ar=array("abba","boomer","boston","abba","bozer");
$ar=array_unique($ar);
?>
output:
Array
(
[3] => abba
[1] => boomer
[2] => boston
[4] => bozer
)
This is much faster and the indexesare not messed up...
----
Manual Page -- http://www.php.net/manual/en/function.array-flip.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56471
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56471&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56471&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56471&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56471&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56471&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56471&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56471&report=yes
Search -- http://master.php.net/manage/user-notes.php