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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -