If you want to check if there are for example only strings in an array, you can use a combination of array_sum and array_map like this:
<?php
function only_strings_in_array($arr) {
return array_sum(array_map('is_string', $arr)) == count($arr);
}
$arr1 = array('one', 'two', 'three');
$arr2 = array('foo', 'bar', array());
$arr3 = array('foo', array(), 'bar');
$arr4 = array(array(), 'foo', 'bar');
var_dump(
only_strings_in_array($arr1),
only_strings_in_array($arr2),
only_strings_in_array($arr3),
only_strings_in_array($arr4)
);
?>
This will give you the following result:
bool(true)
bool(false)
bool(false)
bool(false)