Syntax for is_array() Function
is_array(variable);
Parameter Description
variable Specifies the variable to check
Example(1)
$variable1=1;
$variable2=array('BIKE_1', 'BIKE_2', 'BIKE_3');
if (is_array($variable1))
echo "variable1 is a array value";
else
echo "variable1 is not a array value";
if (is_array($variable2))
echo "<h1>variable2 is an array </h1>";
else
echo "<h1>variable2 is not a array value</h1>";
<!DOCTYPE html>
<html>
<head>
<title>How to use PHP is_array() function with example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<br>
<br>
<br>
<div class="text-center">
<h1>PHP is_array() function</h1>
</div>
<br>
<br>
<h2></h2>
<div class="well">
<?php
// PHP code to demonstrate working of is_array()
$variable1=1;
$variable2=array('BIKE_1', 'BIKE_2', 'BIKE_3');
// $variable_name1 is not array, gives FALSE
if (is_array($variable1))
{
echo "<h1>variable1 is a array value</h1>";
}
else
{
echo "<h1>variable1 is not a array value</h1>";
}
// $variable2 is an array, returns TRUE
if (is_array($variable2))
{
echo "<h1>variable2 is an array </h1>";
}
else
{
echo "<h1>variable2 is not a array value</h1>";
}
?>
</div>
<br>
</div>
</body>
</html>