title: php multidimensional array - how to find min value and return key
body: <p>I have a unique problem that I cannot seem to find an answer to.</p>
  
  <p>I ultimately want to find the index of the array that has the min value on 'price'.</p>
  
  <pre><code>$r = array (
  array('id' =&gt; 1526,'name'=&gt;"Expedited Parcel",'day'=&gt;1,'price'=&gt;10),
  array('id' =&gt; 1234,'name'=&gt;"XpressPost Parcel",'day'=&gt;2,'price'=&gt;20),
  array('id' =&gt; 5345,'name'=&gt;"Internation Shipping",'day'=&gt;7,'price'=&gt;100),
  array('id' =&gt; 1332,'name'=&gt;"Snail Mail Shipping",'day'=&gt;15,'price'=&gt;10));
  </code></pre>
  
  <p>You might also notice that the 'price' has duplicate values of 10. In this case, would it be possible to then compare the <code>$r[0]['day']</code> and <code>$r[3]['day']</code> values and then come up with <code>$index=0</code>? And if PRICE and DAY are the same, then either one is fine.</p>
  
  <p>The result I'd like would be <code>print "Free Shipping".$r[$index]['name']." ".$r[$index]['day']." Business Days".</code></p>
  
  <p><strong>EDIT</strong>
  I found out my array is different, there is no index but now a name reference.</p>
  
  <p><code>$r = array (
  'DOM.EP' =&gt; array('id' =&gt; 1526,'name'=&gt;"Expedited Parcel",'day'=&gt;1,'price'=&gt;10),
  'DOM.PC' =&gt; array('id' =&gt; 1234,'name'=&gt;"XpressPost Parcel",'day'=&gt;2,'price'=&gt;20),
  'DOM.IS' =&gt; array('id' =&gt; 5345,'name'=&gt;"Internation Shipping",'day'=&gt;7,'price'=&gt;100),
  'DOM.SM' =&gt; array('id' =&gt; 1332,'name'=&gt;"Snail Mail Shipping",'day'=&gt;15,'price'=&gt;10)
  );</code></p>
  
  <p><strong>LAST EDIT</strong> Thank you everyone for your help! I've gone ahead and combined code @Kolob Canyon and also @sathish R to get my final code.</p>
  
  <pre><code>$min = 9999999999;
  $minDay = 9999999999;
  $idx = null;
  foreach ($r as $key =&gt; $value) {
      if($min &gt; $r[$key]['price']) {
              $min = $r[$key]['price'];
              $minDay = $r[$key]['day'];
              $idx = $key;
          } 
          else if ($min == $r[$key]['price']) {
              if ($minDay &gt; $r[$key]['day']){
                  $minDay = $r[$key]['day'];
                  $idx = $key;
              }
          }
  }
  
  if($idx != null) {
          echo "Free Shipping ". $r[$idx]['name'] . " " . $r[$idx]['day'] . " Business Days";
      }
  </code></pre>