Reputation: 39
I have an array like this:
$array = array('static_value_1', 'static_value_2', 'extra_value_1', 'extra_value_2');
How could I return true if any value exists in array in addition to static_value_1 and/or static_value_2?
For example this array should return true:
array = array('static_value_1', 'static_value_2', 'extra_value_1');
and this one false:
array = array('static_value_1', 'static_value_2');
Thanks!
Upvotes: 0
Views: 54
Reputation: 1638
I think just looping looking for non-static should work:
function check_array($check) {
$static=Array('static_value_1', 'static_value_2');
// Dealing with empty array.
if(count($check)==0) return false;
foreach($check as $value) {
// If value is not in static collection is an addition...
if(!in_array($value, $static)) {
return false;
}
}
return true;
}
Upvotes: 1