PHP获取二维数组高低点

  1. PHP获取二维数组Kline 开,高,低,收

  2. $data = [
            [
                "open" => "9263.8",
                "high" => "9263.8",
                "low" => "9256",
                "close" => "9259.4"
            ],
            [
                "open" => "9260",
                "high" => "9260.6",
                "low" => "9255.1",
                "close" => "9255.1"
            ],
            [
                "open" => "9255.1",
                "high" => "9257.5",
                "low" => "9254.9",
                "close" => "9257.5"
            ]
    ];

    foreach ($data as $key=>$val) {
        $opens[] = $val["open"];
        $highs[] = $val["high"];
        $lows[] = $val["low"];
        $closes[]= $val["close"];
    }

    $new_arr["open"] = (double)reset($opens);
    $new_arr["high"] = (double)max($highs);
    $new_arr["low"] = (double)min($lows);
    $new_arr["close"] = (double)end($closes);
    var_dump($new_arr);

你可能感兴趣的:(PHP,php)