$imply use array filter which will remove any empty or falsey items from the array, then check if anything is left:
if(empty(array_filter($array)))
If you want to consider spaces empty, for example someone just puts blank space in the field you can throw in an array map with trim as the callback, like this:
if(empty(array_filter(array_map('trim',$array))))
Test It
$a = [
"1" => null,
"2" => null
];
if(empty(array_filter($a))) echo 'empty';
Output
empty
Sandbox
array_filter — Filters elements of an array using a callback function
Iterates over each value in the array passing them to the callback function. If the callback function returns true, the current value from array is returned into the result array. Array keys are preserved.
PHP will consider several things as falsy and remove them, you can supply your own callback if you need finer control, but some of things considered falsy
0
"0"
""
false
null
[] //this is what you get after filtering $array
There may be others, but this should give you the idea.
Because array filter returns an empty array [] which is also falsy you can even just do this if you don't want to call empty
if(!array_filter($array))
But it makes the code a bit less readable because it depends on PHP's loose typing where when empty is used the intent is crystal clear.
if(empty(array_filter($array)), You can also doempty(array_filter(array_map('trim',$array)))if you want to consider spaces empty