如何分离和提取多维数组

How is it possible to separate an array depending on its multi-dimentional depth?

so if I have

array("string","array","string");

i want to be able to process them in a different argument

so for instance

if(string){do somthing};
if(array){do something else};

this is for a query builder so it may not come in this particular order

thank you

Please try below code.

Use is_array and is_string function.

$temp = array('abcd',array(1,2,3),'pqr'); // example array contains string and array both.

foreach($temp as $value){ 
   if(is_array($value)){ // true if variable value is an array.
     echo "array"; print PHP_EOL;
   }else if(is_string($value)){// true if variable value is a string.
    echo "string"; print PHP_EOL;
   }
}