确定PHP数组中的维数 [英] Determine number of Dimensions in a PHP Array
本文介绍了确定PHP数组中的维数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以确定PHP数组中有多少维?
Is there a way to determine how many dimensions there are in a PHP array?
推荐答案
很好的问题,这是我从PHP手册中窃取的解决方案:
function countdim($array)
{
if (is_array(reset($array)))
{
$return = countdim(reset($array)) + 1;
}
else
{
$return = 1;
}
return $return;
}
这篇关于确定PHP数组中的维数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文