Home > Backend Development > PHP Problem > How to use php is_array()

How to use php is_array()

青灯夜游
Release: 2023-03-12 17:00:01
Original
2630 people have browsed it

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.

How to use php is_array()

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 )
Copy after login

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(&#39;天蓬/猪老师&#39;, &#39;灭绝师妹&#39;, &#39;欧阳克&#39;, &#39;西门大官人&#39;);
if(is_array($arr_site)){
    echo &#39;变量 $arr_site 是一个数组&#39;;
} else {
    echo &#39;变量 $arr_site 不是一个数组&#39;;
}
?>
Copy after login

Output result:

How to use php is_array()

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!

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