 <p>This is most optimal way</p> <pre><code>if (is_array($data) &amp;&amp; isset($data['yes'])) { } </code></pre> <p>If you do <code>array_key_exists</code> without checking if <code>$data</code> is array, you will get error, because second parameter for the <code>array_key_exists</code> function must always be type of <code>array</code></p> <p><a href="http://php.net/manual/en/function.array-key-exists.php" rel="nofollow">http://php.net/manual/en/function.array-key-exists.php</a></p>