PHP | is_array()
is_array() is an inbuilt function in PHP. The is_array() function is used to check whether a variable is an array or not.
Below the example illustrate the working of the function is_array(). Example 1:Syntax:
is_array($variable_name) Parameter: contains a single parameter. $variable_name: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.
<?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"; ?> |
chevron_right
filter_none
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
Recommended Posts:
- Underscore.js | _.isArray()
- AngularJS | angular.isArray() Function
- When to use Vanilla JavaScript vs jQuery ?
- How to detect the user browser ( Safari, Chrome, IE, Firefox and Opera ) using JavaScript ?
- How to animate scrollTop using jQuery ?
- How to select text nodes using jQuery ?
- Why require_once() function is so bad to use in PHP ?
- How to convert arguments object into an array in JavaScript ?
- HTML | DOM FocusEvent
- PHP | Imagick setCompression() Function
- PHP | Imagick getImageAlphaChannel() Function
- HTML5 | MathML <munderover> Tag
- PHP | image_type_to_extension() Function
- PHP | Imagick setFormat() Function
- PHP | Imagick getImage() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



