Here is the function for this problem:
function slice_array_depth($array, $depth = 0) { foreach ($array as $key => $value) { if (is_array($value)) { if ($depth > 0) { $array[$key] = slice_array_depth($value, $depth - 1); } else { unset($array[$key]); } } } return $array; }
Use this function to split the array to the depth you need, than just var_dump() or print_r() sliced ββarray :)
Dan kk
source share