note 64454 deleted from function.array-unique by cmb
| From: | cmb@php.net | Date: | Sun, 27 Oct 2019 08:42:07 +0000 |
| Subject: | note 64454 deleted from function.array-unique by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212800@lists.php.net to get a copy of this message | ||
Note Submitter: MoD
----
The shortest way i found to remove duplicate array from a column,
For example if you parse Multiple XML sources, you can remove duplicate items that contain the same
link.
<?PHP
function remove_duplicate($array, $field)
{
foreach ($array as $sub)
$cmp[] = $sub[$field];
$unique = array_unique($cmp);
foreach ($unique as $k => $rien)
$new[] = $array[$k];
return $new;
}
?>