PHP If / Else Multiple Conditions

From what I've read, if statement conditionals should break as soon as a false is found however:

if(array_key_exists('cool', $_POST) && $_POST['cool'] == 1)

returns an index undefined error. What I want to do is check to see if the key is even there and then check it's value, but the only way I've been able to do that is:

if(array_key_exists('cool', $_POST)) {
  if($_POST['cool'] == 1)

and that means I have to have multiple else blacks as well. Is there anyway to do this with less code?

You can use isset which is a language construct as opposed to a function call:

if(isset($_POST['cool']) && $_POST['cool'] == 1)

You need to check if the key exists in the array:

if(array_key_exists('cool',$_POST) && $_POST['cool'] == 1)

or use isset().

Try this

if(array_key_exists('cool',$_POST) && $_POST['cool'] == 1)