php in_array multiple values

Can you use in_array to see if an array contains multiple values.  Here is how I have been using it.

if (in_array("10527", $PayPalResult)) {
    $url_var = "card_number&card_type&";
}

Open in new window


how would I also check for the value 10510 in the same if statement?
LueyAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
If you look at the documentation, it demonstrates passing an array as the "needle". Just create a new array with the corresponding values being sought.

e.g.

$to_find = array("10527", "10510");

if (in_array($to_find, $PayPalResult)) {
    $url_var = "card_number&card_type&";
}

Open in new window

0
 
LueyAuthor Commented:
@ kaufmed   I have tried your code and cannot make it work.  I have looked at the documentation and agree that it should work according to the documentation. I can use either number (10527, 10510) by themselves and it works perfect.  But in the array it does not.  Any suggestions.  I know it is not my other codes because I have stripped it down to just this and it still does not work.
0
 
LueyAuthor Commented:
This does work the way I asked the question.  However I need it to work more like an "or".  I need to know if 10527 or 10510 is in the array I cannot make it work for that.
0
 
LueyAuthor Commented:
This made it work like I needed it to.  

if (in_array("10527", $PayPalResult) or in_array("10510", $PayPalResult)) {
    $url_var = "card_number&card_type&";
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.