Last active
December 29, 2016 15:44
-
-
Save d30jeff/4569b63233710833228e90ddf235f6c4 to your computer and use it in GitHub Desktop.
No description
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$value = 'deojeff'; | |
$array = [ | |
[ | |
'tourney_id' => 1, | |
'player_1' => 'xxx', | |
'player_2' => 'yyy', | |
'player_3' => 'ttt', | |
'player_4' => 'ppp', | |
'player_5' => 'lpsldpsd', | |
], | |
[ | |
'tourney_id' => 2, | |
'player_1' => 'deojeff', | |
'player_2' => 'two', | |
'player_3' => 'three', | |
'player_4' => 'fffour', | |
'player_5' => 'ffive', | |
], | |
[ | |
'tourney_id' => 3, | |
'player_1' => 'chuck_norris', | |
'player_2' => 'obama', | |
'player_3' => '333', | |
'player_4' => '4444', | |
'player_5' => '5555', | |
], | |
]; | |
foreach (range(1, 5) as $i) { | |
if (in_array($value, array_column($array, "player_{$i}"))) { | |
echo 'Name exists'; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment