You could combine the array_keys() function with recursion to grab all keys inside your array like shown below:
// Your given array
$array = [
8 => [
9 => [
13 => []
]
],
14 => [
15 => []
]
];
// What this function does, is it loops through the array, and if the given
// value is an array too, it does the same until it hits a value which is not an array
function array_keys_recursive($array, $keys = []) {
foreach ($array as $key => $value) {
$keys[] = $key;
if (is_array($value)) {
$keys = array_merge($keys, array_keys_recursive($value));
}
}
return $keys;
}
// You call it like a so:
$keys = array_keys_recursive($array);
print_r($keys); // Outputs Array ( [0] => 8 [1] => 9 [2] => 13 [3] => 14 [4] => 15 )