How to check if multiple array keys exists
问题 I have a variety of arrays that will either contain story & message or just story How would I check to see if an array contains both story and message? array_key_exists() only looks for that single key in the array. Is there a way to do this? 回答1: If you only have 2 keys to check (like in the original question), it's probably easy enough to just call array_key_exists() twice to check if the keys exists. if (array_key_exists("story", $arr) && array_key_exists("message", $arr)) { // Both keys