note 113889 modified in function.array-unique by levim
| From: | levim@php.net | Date: | Sun, 20 Dec 2015 05:49:27 +0000 |
| Subject: | note 113889 modified in function.array-unique by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-204502@lists.php.net to get a copy of this message | ||
If you find the need to get a sorted array without it preserving the keys, use this code which has
worked for me:
<?php
$array = array("hello", "fine", "good", "fine",
"hello", "bye");
$get_sorted_unique_array = array_values(array_unique($array));
?>
The above code returns an array which is both unique and sorted from zero.
--was--
if you fine the need to get a sorted array without it preserving the keys, use this code which has
worked for me:
$array = array("hello", "fine", "good", "fine",
"hello", "bye");
$get_sorted_unique_array = array_values(array_unique($array));
// the above code returns an array which is both unique and sorted from zero.
http://php.net/manual/en/function.array-unique.php