dousi1961 2008-10-30 20:40
浏览 30
已采纳

too long

Does anybody knows how can I get the max and min value of the 2nd and 3rd columns in PHP?

$ar = array(array(1,  10,   9.0,   'HELLO'),
            array(1,  11,  12.9,   'HELLO'),
            array(3,  12,  10.9,   'HELLO'));

Output should be like:

max(12.9) min(10)

  • 写回答

2条回答 默认 最新

  • douxiong4250 2008-10-30 20:50
    关注
    <?php
    $ar = array(array(1,  10,   9.0,   'HELLO'),
                array(1,  11,  12.9,   'HELLO'),
                array(3,  12,  10.9,   'HELLO'));
    function col($tbl,$col){
        $ret = array();
        foreach ($tbl as $row){
            $ret[count($ret)+1] = $row[$col];
        }
        return $ret;
    }
    print (max(col($ar,2))."
    ");
    print (min(col($ar,1))."
    ");
    ?>
    

    is this what you look for? I guess its not the most efficient way.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析