php - Search an array[key] for any integer but one -
i stumped while searching answer, have array contains information relating tournament, seen below.
i search through array of arrays opponent key, , determine if -2. because logic -2 bye, if people have -2 opponent, means brackets have been finished.
my initial thought array_search(!(-2), $anarray)
, didn't work , hit myself on head thinking easy haha. thanks.
ex:
array ( [0] => array ( [did] => 11 [uid] => 3 [id] => 1 [round] => 0 [opponent] => 3 [bracket] => 0 ) [1] => array ( [did] => 11 [uid] => 5 [id] => 2 [round] => 0 [opponent] => -2 [bracket] => 1 ) [2] => array ( [did] => 11 [uid] => 10 [id] => 3 [round] => 0 [opponent] => 1 [bracket] => 0 ) )
this function return true if opponents -2 , false if there single opponent != -2:
function all_opponent_search($arr){ for($i = 0; $i < count($arr); $i++) if($arr[$i]['opponent'] != -2) return false; return true; }
Comments
Post a Comment