I have the following array:
array(4) {
[29] => NULL
[31] => NULL
[33] => NULL
[35] => NULL
}
I would like to test all keys if all keys contain NULL values.
if(count(array_filter($input, 'is_null')) == count($input)) {
}
should be what you are looking for :)
// need php version >= 5.3 or you need to define a function, or just use a loop to check.
if (!count(array_filter($your_array, function($var){return $var !== null}))) {
// all values is null.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With