title: Loop until array is empty, condition isn't correct
body: <p>I have two arrays in which I mixed keys and values until one of the arrays is empty. But my loop is execute endless. If key from arrayOne is bigger than arrayTwo. Value is dropped from arrayTwo and added to arrayOne. This is my code </p>
  
  <pre><code>$cardsOfPlayerOne = array(
              "karo" =&gt; array(
                  '1' =&gt; 'dwa',
                  '2' =&gt; 'trzy'
              ),
              "kier" =&gt; array(
                  '3' =&gt; 'dwa',
                  '4' =&gt; 'trzy'
              ));
  
  $cardsOfPlayerTwo = array(
  
              "trefl" =&gt; array(
                  '5' =&gt; 'dwa',
                  '6' =&gt; 'trzy'
              ),
              "pik" =&gt; array(
                  '7' =&gt; 'dwa',
                  '8' =&gt; 'trzy'
              ));
  
  
  while (!empty($cardsOfPlayerOne) OR !empty($cardsOfPlayerTwo)){
  
      $cardKeyOne = array_rand($cardsOfPlayerOne);
      $cardKeyTwo = array_rand($cardsOfPlayerTwo);
  
      $cardStrenghtOne = array_rand($cardsOfPlayerOne[$cardKeyOne]);
      $cardStrenghtTwo = array_rand($cardsOfPlayerTwo[$cardKeyTwo]);
  
      if($cardStrenghtOne &gt; $cardStrenghtTwo){
  
          if(!isset($cardsOfPlayerOne[$cardKeyTwo][$cardStrenghtTwo])){
              $cardsOfPlayerOne[$cardKeyTwo][$cardStrenghtTwo] = array();
          }
  
          $cardsOfPlayerOne[$cardKeyTwo][$cardStrenghtTwo] = $cardsOfPlayerTwo[$cardKeyTwo][$cardStrenghtTwo];
          unset($cardsOfPlayerTwo[$cardKeyTwo][$cardStrenghtTwo]);
  
  
          if(empty($cardsOfPlayerTwo[$cardKeyTwo])){
              unset($cardsOfPlayerTwo[$cardKeyTwo]);
          }
  
      }
      else{
  
          if(!isset($cardsOfPlayerTwo[$cardKeyOne][$cardStrenghtOne])){
              $cardsOfPlayerTwo[$cardKeyOne][$cardStrenghtOne] = array();
          }
  
          $cardsOfPlayerTwo[$cardKeyOne][$cardStrenghtOne] = $cardsOfPlayerOne[$cardKeyOne][$cardStrenghtOne];
          unset($cardsOfPlayerOne[$cardKeyOne][$cardStrenghtOne]);
  
          if(empty($cardsOfPlayerOne[$cardKeyOne])){
              unset($cardsOfPlayerOne[$cardKeyOne]);
          }
  
  
      }
  
  
  
  }
  </code></pre>
  
  <p>And code online <a href="http://ideone.com/bPDMea" rel="nofollow">LINK</a></p>