title: PHP Array_diff when there are duplicate array values
body: <p>I have two arrays containing repeating values:</p>
  
  <pre><code>$test1 = Array(
          "blah1",
          "blah1",
          "blah1",
          "blah1",
          "blah2"
      );
  
      $test2 = Array(
          "blah1",
          "blah1",
          "blah1",
          "blah2"
      );
  </code></pre>
  
  <p>I am trying to get array difference:</p>
  
  <pre><code>$result = array_diff($test1,$test2);
  
  echo "&lt;pre&gt;";
  print_r($result);
  </code></pre>
  
  <p>I need it to return array with single value <code>blah1</code>, yet it returns empty array instead...</p>
  
  <p>I suspect it has something to do with fact there are duplicate values in both arrays, but not sure how to fix it...</p>
  
  <p>Please help!!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>End up writing this function to do the trick:</p>
  
  <pre><code>function subtract_array($array1,$array2){
      foreach ($array2 as $item) {
          $key = array_search($item, $array1);
          unset($array1[$key]);
      }
      return array_values($array1);
  }
  </code></pre>