Home > Article > Backend Development > How to use php is_array()
In PHP, the is_array() function can be used to detect whether a variable is an array, the syntax is "is_array($var)"; the return value of this function is of bool type, if the detected parameter var is an array , it returns true, otherwise it returns false.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php is_array() function
PHP is_array() function is used to determine whether a variable is an array. Its syntax is as follows:
bool is_array ( mixed $var )
Parameter description:
$var : The variable to be tested.
Return value
If the detected variable is an array, TRUE is returned, otherwise FALSE is returned.
The usage example of this function is as follows:
<?php header("Content-type:text/html;charset=utf-8"); $arr_site = array('天蓬/猪老师', '灭绝师妹', '欧阳克', '西门大官人'); if(is_array($arr_site)){ echo '变量 $arr_site 是一个数组'; } else { echo '变量 $arr_site 不是一个数组'; } ?>
Output result:
Recommended learning: php training
The above is the detailed content of How to use php is_array(). For more information, please follow other related articles on the PHP Chinese website!