doufeikuang7724
2016-09-14 03:56
浏览 28
已采纳

PHP:如何获得密钥的最低数组值

I have a an array and I need to get the lowest value together of key. Because i need to check if the value has contain the right key or not

 Array ( 
      [120] => 97.00 
      [132] => 92.67 
      [124] => 72.33 
      [131] => 49.67 
      [129] => 25.00 
      [127] => 25.00 //<--Get the value and this key
  )
  //This array already sorted, no need to sort just get the last value and key

How can i get the lowest value 25.00 together the key [127]

 $array = array (

      "120" => 97.00 
      "132" => 92.67 
      "124" => 72.33 
      "131" => 49.67 
      "129" => 25.00 
      "127" => 25.00 

  );

  print_r(min($array)); //<--displaying only the value but not the key

The output should be like

127 - 25.00

图片转代码服务由CSDN问答提供 功能建议

我有一个数组,我需要得到密钥的最低值。 因为我需要检查值是否包含正确的键

  Array(
 [120] =&gt; 97.00 
 [132] =&gt; 92.67 \  n [124] =&gt; 72.33 
 [131] =&gt; 49.67 
 [129] =&gt; 25.00 
 [127] =&gt; 25.00 //&lt;  - 获取值和此键
)  
 //这个数组已经排序了,不需要排序只是得到最后一个值和键
   
 
 

如何在键中得到最低值25.00 [127 ]

  $ array = array(
 
“120”=&gt; 97.00 
“132”=&gt; 92.67 
“124”=&gt; 72.33 \  n“131”=&gt; 49.67 
“129”=&gt; 25.00 
“127”=&gt; 25.00 
 
); 
 
 print_r(min($ array));  //&lt;  - 仅显示值但不显示键
   
 
 

输出应该类似于

   127  -  25.00 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

相关推荐 更多相似问题