PHP Conference Kansai 2025

Voting

: seven minus one?
(Example: nine)

The Note You're Voting On

zoolyka at gmail dot com
9 years ago
I found the simplest way to "unique" multidimensional arrays as follows:

<?php

$array
= array(
'a' => array(1, 2),
'b' => array(1, 2),
'c' => array(2, 2),
'd' => array(2, 1),
'e' => array(1, 1),
);

$array = array_map('json_encode', $array);
$array = array_unique($array);
$array = array_map('json_decode', $array);

print_r($array);

?>

As you can see "b" will be removed without any errors or notices.

<< Back to user notes page

To Top