dongyushen9063 2012-07-26 09:38
浏览 78
已采纳

在没有循环的情况下查找数组中的最小值? (PHP)

I have this array:

$myArray = array("0x40x40" => 64, "0x50x40" => 65, "0x60x40" => 66);

Now I want to find the smalles value, in this case its 64 (the first key/value pair). Is there a way other than looping through the array and to compare the values? The smallest value is not always the first and the values are not sorted by the way.

Thanks!

  • 写回答

5条回答 默认 最新

  • dtrj74376 2012-07-26 09:41
    关注

    You can use the min() function to get your answer nicely.

    echo min(2, 3, 1, 6, 7); // 1

    or

    $myArray=array(2, 3, 1, 6, 7);
    echo min($myArray); // 1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效