Thursday, February 19, 2026
HomeLanguagesPHP | is_array() Function

PHP | is_array() Function

The is_array() is an inbuilt function in PHP. The is_array() function is used to check whether a variable is an array or not.

Syntax:

bool is_array($variable_name)

Parameter: This function accept a single parameter as mentioned above and described below:
$variable_name: This parameter holds the variable we want to check.

Return value: It is a boolean function so returns TRUE when $variable_name is a boolean value, otherwise FALSE.

Below example illustrate the is_array() function in PHP.
Example 1:




<?php
// PHP code to demonstrate working of is_array()
$variable_name1=67.099;
$variable_name2=32;
$variable_name3="abc";
$variable_name4=array('A', 'B', 'C');
  
// $variable_name4 is an array, returns TRUE
if (is_array($variable_name4))
    echo "array('A', 'B', 'C') is an array . \n";
else
    echo "array('A', 'B', 'C') is not a array value. \n";
  
  
// $variable_name1 is not array, gives FALSE
if (is_array($variable_name1))
    echo "$variable_name1 is a array value. \n";
else
    echo "$variable_name1 is not a array value. \n";
  
// $variable_name2 is not array, gives FALSE
if (is_array($variable_name2))
    echo "$variable_name2 is a array value. \n";
else
    echo "$variable_name2 is not a array value. \n";
  
// $variable_name3 is not array, gives FALSE
if (is_array($variable_name3))
    echo "$variable_name3 is a array value. \n";
else
    echo "$variable_name3 is not a array value. \n";
?>


Output:

array('A', 'B', 'C') is an array . 
67.099 is not a array value. 
32 is not a array value. 
abc is not a array value.

Reference: http://php.net/manual/en/function.is-array.php

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS