开发者

Remove all sub arrays for multidimensional array in PHP

开发者 https://www.devze.com 2022-12-11 19:34 出处:网络
What is a simple mode, in PHP, to remove all the sub arrays of a multidimensional array? What I want is to remove all the开发者_如何学Go sub arrays but the top one...

What is a simple mode, in PHP, to remove all the sub arrays of a multidimensional array? What I want is to remove all the开发者_如何学Go sub arrays but the top one...

Thanks, titel


foreach($array as $k => $a) {
    if (is_array($a)) { unset($array[$k]); }
}

Like this?


function FlattenCallback($Value) { return !is_array($Value); }

$OneDimension = array_filter($MultiDimension, 'FlattenCallback');
0

精彩评论

暂无评论...
验证码 换一张
取 消