- print_r: documentation ( source)
- array_walk_recursive: documentation ( source)
<?php
$array = [
'1' => true,
['2' => false, '4' => true],
'3' => true
];
$matches = [];
array_walk_recursive($array, function ($value, $key) use (&$matches) {
if ($value === true) {
$matches[] = $key;
}
});
print_r($matches);