I have an array that looks like this:
$team = array("tom"=>"35",
"beck"=>"18",
"Gerald"=>"15");
I also am parsing data from a loop which gives me the following strings $name and $num
- The $name string returns a team members name from a database
- The $num string returns a team members number from a database
I would like to build a php if statement that will do the following:
- Check if the $name and $num exists in the array $team
- Check if the $num matches the assigned number for the name in the array
As an example, lets assume the following:
- $name = "tom";
- $num = "25";
I have this so far:
if (in_array($num, $team)) {
// do something
}
What's missing is for it to check the second condition mentioned above.
Following the above example, it should fail, since the $num value is "25", whereas it is "35" in the array.