Tuesday 6 April 2021

Php: is_array(): Chek whether a variable is an array

Signature

is_array ( mixed $value ) : bool

 

Description

Finds whether the given variable is an array. Returns true if value is an array, false otherwise.

 

Example

$is_arr1_array = is_array($arr1);

 

is_array_demo.php

#!/usr/bin/php

<?php

    $arr1 = array(22, 31, -5, 77, -98, 18);
    $var1 = 10;
    
    $is_arr1_array = is_array($arr1);
    $is_var1_array = is_array($var1);

    echo "is \$arr1 array ? ";
    var_dump($is_arr1_array);
    echo "\nis \$var1 array ? ";
    var_dump($is_var1_array);
?>

 

Output

$./is_array_demo.php 

is $arr1 array ? bool(true)

is $var1 array ? bool(false)

 

 

 

  

Previous                                                    Next                                                    Home

No comments:

Post a Comment