I have an array. How can I get a list of the keys that have null values? Is there some short way to find them?
2 Answers
Actually, array_keys has an optional search_value parameter, so you can just put:
array_keys($array, null, true);
You must set the third parameter (strict comparison) to true for it to match only nulls.
1 Comment
JohnK
Thanks! This is the kind of answer I was looking for. Very educational!