title: PHP Array compare using loops
body: <p>I am using this piece of code to compare two php arrays, I got all matched items rightly but unfortunately i am not succeeding in getting non matched items. Here is my code.</p>
  
  <pre><code>&lt;?php 
  
  $filter1 = "blueberries,abc,cornstarch,sugar";
  $cval = strtoupper($filter1);         
  $parts1 = explode(',',$cval);
  
  $filter2 = "water,blueberries,sugar,cornstarch";
  $values = strtoupper($filter2);
  $parts2 = explode(',', $values);
  
  
  $m=0;
  $nm=0;
  
  
  for($i = 0; $i&lt; count($parts1); $i++)
  {
  
  for($j = 0; $j&lt; count($parts2); $j++)
  {
  
  if($parts1[$i] == $parts2[$j])
  {
  $m++;
  $p[] = $parts1[$i];
  }
  else{
  $nm++;
  $q[] = $parts1[$i];
  }
  
  }
  
  }
  
  echo $m;
  echo "&lt;br /&gt;";
  echo $nm;
  echo "&lt;br /&gt;";
  print_r($p);
  echo "&lt;br /&gt;";
  print_r($q);
  
  ?&gt;
  </code></pre>
  
  <p>Can someone help me sorting out this problem, As i <strong>dont want to use builtin array comparison functions.</strong> </p>