title: How to get common minimum value in two arrays
body: <p>I have a function where is checks on two arrays and returns the common minimum value in both the arrays. IT returns the correct answer when both the arrays have equal number of elements. But is the other other is bigger it does not return the correct one. How to overcome this?</p>
  
  <pre><code>&lt;?php
      $A = array(0);
      $B= array(1,0);
      $n = sizeof($A);
      $m = sizeof($B);
      sort($A);
      sort($B);
      $i = 0;
      for ($k = 0; $k &lt; $n; $k++) {
          if ($i &lt; $m - 1 AND $B[$i] &lt; $A[$k])
              $i += 1;
          if ($A[$k] == $B[$i])
              echo $A[$k];
      }
      echo "end";
  
  ?&gt;
  </code></pre>
  
  <p>Thanks</p>