What is the function in php to determine whether it is an array?

青灯夜游
Release: 2023-03-16 12:38:01
Original
2929 people have browsed it

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.

What is the function in php to determine whether it is 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($变量名)
Copy after login

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(&#39;content-type:text/html;charset=utf-8&#39;);   
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);
?>
Copy after login

What is the function in php to determine whether it is an array?

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!

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