1

I will try my best to explain this, I have the following array which has multiple values. I am trying to use isset to check if two values are within the array. I have followed the php documentation here: http://php.net/manual/en/function.isset.php

$nfl = array(#stands for national footbal league
    'patriots' => 'New England Patriots',
    'jets' => 'New York Jets', etc..........)



       if(isset($nfl[$team11][$team12]) )
        {
   # my code is here
    }

If I use only one team it works

if(isset($nfl[$team]))

Can anyone help me please?

1 Answer 1

4

You have to check them one at a time but you can do that in one function call as isset() accepts multiple variables to check.

If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set. Evaluation goes from left to right and stops as soon as an unset variable is encountered.

if(isset($nfl[$team11], $nfl[$team12])) { // all must be true
    // do stuff
}
Sign up to request clarification or add additional context in comments.

1 Comment

Using a comma instead of extra && and extra issets sure saves a lot of keystrokes, not to mention finger wear ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.