Let\'s say I have an array like this:
Array ( [id] => 45 [name] => john [children] => Array ( [45] => Array (
This should do it:
function array_values_recursive($arr, $key) { $arr2 = ($key == 'children') ? array_values($arr) : $arr; foreach ($arr2 as $key => &$value) { if(is_array($value)) { $value = array_values_recursive($value, $key); } } return $arr2; }