How do I check to see if a compound key exists with array_key_exists such as
$myarr['ind1']['ind2']
Would like to see if the key [‘ind1’][‘ind2’] exists in $myarr.
I googled this and looked at some similar answers but couldn’t find anything.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can make use of
issetDocs to check for an array member that not equalsNULL, which is the case for a compound array and safe to assume in your case:If
$myarr['ind2']potentially never equals toNULLyou can do the following, which might show better what you’re trying to check:This checks the compound key does exists and is not
NULL.