is_array in php – PHP is_array() Examples

is_array in php – The is_array() method checks whether a variable is an Array or not. It returns Boolean value true / false only.

PHP is_array() Syntax

is_array ( mixed $value );

mixed $value | required : value which you have to check. Since this function only checks, you can pass any type of value.

Understanding mixed Type

Mixed type means that you can pass the value of any type (String, Boolean, Array, Class, Numeric) according to your need. It is not necessary to pass a special type of value only.

Return Value: If value is an array, then true is returned and false is returned in other conditions.

PHP is_array() Example

File : php_is_array.php

<?php 
  $shop_id = [22,44,55,88,55];
  echo is_array($shop_id) ? '$shop_id is an Array' : '$shop_id is an not Array';
  /*Another example*/
  echo "<br>";
  $ex = "String";
  echo is_array($ex) ? '$ex is an Array' : '$ex is an not Array';
?>

Result

$shop_id is an Array
$ex is an not Array

See also :  get domain name in php - Extract domain, path etc from a full url with PHP

Leave a Reply

Your email address will not be published.