Remove duplicates from multidimensional array

Uses serialization to retrieve only unique values from multidimensional array. Read more.

php
fork add to bundle source
function multi_array_unique($array) { return array_map('unserialize', array_unique(array_map('serialize', $array))); }

usage

load_function('multi_array_unique'); $array = [ 0 => ['age' => 19, 'name' => 'John'], 1 => ['age' => '17', 'name' => 'Tina'], 2 => ['age' => 19, 'name' => 'John'] ]; $result = multi_array_unique($array); print_r($result); // Array // ( // [0] => Array // ( // [age] => 19 // [name] => John // ) // // [1] => Array // ( // [age] => 17 // [name] => Tina // ) // // )
← how to use this in app?
create log ...inout