How to check whether a variable is an array – PHP

<?php
 $array = array('this', 'is', 'an array');
 echo is_array($array) ? 'True' : 'False'; // True
 echo "  ";
 $var = 'this is a string';
 echo is_array($no) ? 'True' : 'False'; // False
?>
Share

Leave a Reply

Your email address will not be published. Required fields are marked *