Return to Snippet

Revision: 29122
at July 22, 2010 08:32 by Moridin


Initial Code
// remove duplicate elements from n-dimensional arrays
function uniqueArray($nDimArray) {

    foreach($nDimArray as &$val) {
        $val = serialize($val);
    }
    $nDimArray = array_unique($nDimArray);
    foreach($nDimArray as &$val) {
        $val = unserialize($val);
    }
    return $nDimArray;
}

Initial URL
http://www.php.net/manual/en/function.array-unique.php#84750

Initial Description
Courtesy of Dorphalsig on php.net (see URL above)

Initial Title
Eliminate Duplicates in Multi-Dimensional Arrays

Initial Tags
array

Initial Language
PHP