min and max in multidimensional-array

后端 未结 7 444
深忆病人
深忆病人 2020-12-02 00:44

hi i am trying to find min and max values of x and y how can i find this min and max functions is not working correctly

$dataPoints = array(
 array(\'x\' =&g         


        
7条回答
  •  有刺的猬
    2020-12-02 01:12

    You can find individually the minimum and maximum values of each column by combining array_column, min and max functions:

    $min_x = min(array_column($dataPoints, 'x'));
    $max_x = max(array_column($dataPoints, 'x'));
    $min_y = min(array_column($dataPoints, 'y'));
    $max_y = max(array_column($dataPoints, 'y'));
    

提交回复
热议问题