In PHP, how would one check to see if a specified item (by name, I think - number would probably also work) in an array is empty?
Types of empty (from PHP Manual). The following are considered empty for any variable:
So take the example below:
1) $arr['ele3'] is not set. So: 2) $arr['ele2'] is set, but empty. So: 1) $arr['ele1'] is set and not empty: if you wish to check whether is it empty, simply use the empty() function. |
|||||
|
or
or
depending on what precisely you mean by "empty". See the docs for empty(), isset() and array_key_exists() as to what exactly they mean. |
|||||||||||
|
(for checking if empty result 1 else 0); Compactness is what I persue in my code. |
||||
|