I have some array like this
$arr_dt = array();
foreach ($dt as $r){
$arr_dt[$r->criteria][$r->alternative] = $r->value;
}
How can i get min / max value based on criteria or alternative?
the criteria may have same value, like below
$arr_dt[criteria1][alternative1] = 25;
$arr_dt[criteria1][alternative2] = 64;
$arr_dt[criteria1][alternative3] = 46;
$arr_dt[criteria2][alternative1] = 80;
$arr_dt[criteria2][alternative2] = 100;
$arr_dt[criteria2][alternative3] = 25;
how can i get max value of criteria 1 and criteria 2.
Thank You very much.
Get the max value:
$value = max($array);
Get the corresponding key:
$key = array_search($value, $array);
Try this.