title: How does array_diff work?
body: <p>How does <code>array_diff()</code> work? It obviously couldn't work as follows:</p>
  
  <pre><code>function array_diff($arraya, $arrayb)
  {
      $diffs = array();
      foreach ($arraya as $keya =&gt; $valuea)
      {
          $equaltag = 0;
          foreach ($arrayb as $valueb)     
          {
              if ($valuea == $valueb)
              {
                  $equaltag =1;
                  break;
              }
          }
          if ($equaltag == o)
          {
                $diffs[$keya]=$valuea;
          }
  
      }
      return $diffs;                          
  }                                  //couldn't be worse than this
  </code></pre>
  
  <p>Does anyone know a better solution?</p>
  
  <p>EDIT @animuson:</p>
  
  <pre><code>function array_diff($arraya, $arrayb)
  {
      foreach ($arraya as $keya =&gt; $valuea)
      {
          if (in_array($valuea, $arrayb))
          {
              unset($arraya[$keya]);
          }
      }
      return $arraya;
  }
  </code></pre>