## `is_array` Function: Checking if a Variable is an Array

The `is_array()` function in PHP is used to check if a variable is an array. It returns `true` if the variable is an array, and `false` otherwise.

### Syntax

“`php
bool is_array(mixed $var)
“`

### Parameters

* `$var`: The variable to be checked.

### Return Value

The `is_array()` function returns `true` if the variable is an array, and `false` otherwise.

### Example

“`php
$array = array(1, 2, 3);
$string = “Hello World”;

var_dump(is_array($array)); // true
var_dump(is_array($string)); // false
“`

### Usage

The `is_array()` function is commonly used to check if a variable is an array before performing an operation on it. For example, the following code checks if the `$array` variable is an array before looping through its elements:

“`php
if (is_array($array)) {
foreach ($array as $element) {
echo $element . “\n”;
}
}
“`

The `is_array()` function can also be used to check if a function argument is an array. For example, the following function takes an array as an argument and returns the sum of its elements:

“`php
function sum_array(array $array) {
$sum = 0;
foreach ($array as $element) {
$sum += $element;
}
return $sum;
}
“`

### Conclusion

The `is_array()` function is a simple but useful function that can be used to check if a variable is an array. This can be helpful when working with arrays and performing operations on them.