Dainius Vaičiulis Dainius Vaičiulis - 1 year ago 83
PHP Question

PHP - elegant way to check if assoc array value has a subarray?

Is there any elegant way to check if

has any

Answer Source

Try with is_array(). It will check if it is an array or not -

if(is_array($review['passenger'])) {
   // is an array

Or if you want to check if some key is present or not then -

if(array_key_exists('key', $review['passenger'])) { ... }