note 12794 deleted from function.array-unique by felipe
| From: | felipe@php.net | Date: | Sat, 29 Dec 2007 20:51:09 +0000 |
| Subject: | note 12794 deleted from function.array-unique by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134214@lists.php.net to get a copy of this message | ||
Note Submitter: mads dot rebsdorf at am-vision dot dk
----
To unique an array in newer versions of php - i've found this snippet useful:
<?php
// $old[0] = 1
// $old[1] = 1
// $old[2] = 2
// $old[3] = 1
// $old[4] = 2
$new = array();
for($i=0;$i<count($old);++$i){
if(in_array($old[$i], $new) != "true"){
$new[] = $old[$i];
}
}
//$new now contains:
//
//$new[0] = 1
//$new[1] = 2
?>
/mads