note 45892 deleted from function.array-unique by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 22 Sep 2004 19:34:24 +0000 |
| Subject: | note 45892 deleted from function.array-unique by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77208@lists.php.net to get a copy of this message | ||
Note Submitter:
----
My Array_unique function wich conserv key order :
function array_unique($array)
{
$out = array();
// loop through the inbound
$key1 = 0;
foreach ($array as $key=>$value) {
// if the item isn't in the array
if (!in_array($value, $out)) {
// add it to the array
$out[$key1] = $value;
$key1++;
}
}
return $out;
}
Thanks to Justin