If you don't know what the size of the array will be, use a recursive function with a foreach loop that calls itself if each $ val is an array. If you know the size, then simply go through each measurement and write down the keys for each.
Something like that:
<?php
function getKeysMultidimensional(array $array)
{
$keys = array();
foreach($array as $key => $value)
{
$keys[] = $key;
if( is_array($value) ) {
$keys = array_merge($keys, getKeysMultidimensional($value));
}
}
return $keys;
}
source
share