PHP method to determine whether an array is one-dimensional or two-dimensional

小云云
Release: 2023-03-20 14:04:01
Original
5307 people have browsed it

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 "不是一维";  
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!