note 116363 added to function.array-unique
| From: | LudovicoGrossi | Date: | Fri, 19 Dec 2014 14:01:51 +0000 |
| Subject: | note 116363 added to function.array-unique | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201225@lists.php.net to get a copy of this message | ||
You can do a super fast version of array_unique directly in PHP, even faster than the other solution
posted in the comments!
Compared to the built in function it is 20x faster! (2x faster than the solution in the comments).
<?php
function superfast_array_unique($array) {
return array_keys(array_flip($array));
}
?>
This works faster for small and big arrays.
----
Server IP: 72.52.91.14
Probable Submitter: 85.18.214.164
----
Manual Page -- http://php.net/manual/en/function.array-unique.php
Edit -- https://master.php.net/note/edit/116363
Del: integrated -- https://master.php.net/note/delete/116363/integrated
Del: useless -- https://master.php.net/note/delete/116363/useless
Del: bad code -- https://master.php.net/note/delete/116363/bad+code
Del: spam -- https://master.php.net/note/delete/116363/spam
Del: non-english -- https://master.php.net/note/delete/116363/non-english
Del: in docs -- https://master.php.net/note/delete/116363/in+docs
Del: other reasons-- https://master.php.net/note/delete/116363
Reject -- https://master.php.net/note/reject/116363
Search -- https://master.php.net/manage/user-notes.php