PHP has an internal variables handling functions to finds whether a variables is an array
is_array <?php if( is_array($elements) ){ //do your work } ?>
Another fastest way of determining an array is by:
Cast the value to an array, then check using (===) if it is identical to the original.
<?php if ( (array) $elements!== $elements) { echo '$elements is not an array'; } else { echo '$elements is an array'; } ?>
What do you think?