Home > Article > Backend Development > PHP method to determine whether an array is one-dimensional or two-dimensional
How does PHP determine whether an array is one-dimensional or two-dimensional? Below we will use code to teach you how to determine.
1. First we have a PHP built-in function count();
count(array,mode); array是数组,mode默认为0,1是递归的计数 <?php if(count($arr) == count($arr,1)){ echo "是一维"; }else{ echo "不是一维"; }
Related recommendations:
php How to determine the dimension of an array Example code
Commonly used methods for PHP to determine whether an array is empty (five methods)
PHP determines whether the dimensions of an array Array are encapsulated functions
The above is the detailed content of PHP method to determine whether an array is one-dimensional or two-dimensional. For more information, please follow other related articles on the PHP Chinese website!