- var_export: documentation ( source)
- array_walk_recursive: documentation ( source)
<?php
$array = [
1 => [1, 12, 2],
2 => [1, 13, 3],
3 => [1, 12, 2],
4 => [1],
5 => [1]
];
array_walk_recursive($array, function($v)use(&$output) {
if (isset($output[$v])) {
++$output[$v];
} else {
$output[$v] = 1;
}
});
var_export($output);