Home > Article > Backend Development > What is the function in php to determine whether it is an array?
The function in php to determine whether it is an array is "is_array()". The is_array() function can determine whether a specified variable is an array type. The syntax is "is_array($variable name)"; if the return value is true, the specified variable is an array. If the return value is false, the specified variable is not an array.
The operating environment of this tutorial: windows7 system, PHP8.1 version, DELL G3 computer
In php, I want to determine whether a variable For an array, you can use the is_array() function.
is_array() function is used to detect whether a variable is an array.
PHP version requirements: PHP 4, PHP 5, PHP 7
Judgment syntax:
is_array($变量名)
is_array() The return value of the function is a Boolean type :
If the return value is true, the specified variable is an array
If the return value is false, the specified variable is not an array.
Judgment example:
<?php header('content-type:text/html;charset=utf-8'); function f($val){ if(is_array($val)){ echo "该变量是数组类型<br>"; }else{ echo "该变量不是数组类型<br>"; } } $a = array(1,2,3,4,5); $b = 123; f($a); f($b); ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What is the function in php to determine whether it is an array?. For more information, please follow other related articles on the PHP Chinese website!