示例:
Array
(
[0] => stdClass Object
(
[Big] => 1.32
[FAN_MODEL] => AFPV3G-500-2800
[FAN_DIA] => 500
[FAN_RPM] => 2800
[FAN_SERIES_NAME] => AFPV3G
[BigVALUE] => 26.00
[FAN_CMH] => 10000
[BigPEAK_POWER] => 800.00
[Bigoutlet_velocity] => 14.15
[velocity_pressure] => 12.253
[Bigtotal_velocity] => 13.57
[SP1] => 8
[SP2] => 5
[SP3] => 7
[SP4] => 7
[SP5] => 7
[SP6] => 7
[SP7] => 7
[SP8] => 7
[SP9] => 7
[SP10] => 7
[Bigtotal_eff] => 0.33
[static_eff] => 0.03
[BigBKW] => 1.120
)
[1] => stdClass Object
(
[STATIC_PRESSURE] => 0.34
[FAN_DIA] => 630
[FAN_RPM] => 1460
[FAN_MODEL] =>
[FAN_SERIES_NAME] => AFPV3G
[BLADE_ANGLE_VALUE] => 25.00
[FAN_CMH] => 10000
[EQU_PEAK_POWER] => 3601.86
[outlet_velocity] => 8.92
[velocity_pressure] => 4.862
[total_velocity] => 5.20
[SP2] => 14
[SP3] => 42
[SP4] => 41
[SP5] => 1
[SP6] => 4
[SP7] => 4
[SP8] => 4
[SP9] => 4
[SP10] => 1
[total_eff] => 0.29
[static_eff] => 0.19
[BKW] => 0.486
[Big] => 3.86
[BigVALUE] => 26.00
[BigPEAK_POWER] => 360.19
[Bigoutlet_velocity] => 8.92
[Bigtotal_velocity] => 8.72
[SP1] => 1
[Bigtotal_eff] => 0.43
[BigBKW] => 0.547
)
[2] => stdClass Object
(
[SP1] => 1
[FAN_MODEL] =>
[Big] => 3.86
[FAN_DIA] => 630
[FAN_RPM] => 1460
[FAN_SERIES_NAME] => AFPV3G
[BigVALUE] => 26.00
[FAN_CMH] => 10000
[BigPEAK_POWER] => 360.19
[Bigoutlet_velocity] => 8.92
[velocity_pressure] => 4.862
[Bigtotal_velocity] => 8.72
[SP2] => 14
[SP3] => 42
[SP4] => 41
[SP5] => 1
[SP6] => 4
[SP7] => 4
[SP8] => 4
[SP9] => 4
[SP10] => 1
[Bigtotal_eff] => 0.43
[static_eff] => 0.19
[BigBKW] => 0.547
)
[3] => stdClass Object
(
[Big] => 23.69
[FAN_MODEL] =>
[FAN_DIA] => 710
[FAN_RPM] => 1450
[FAN_SERIES_NAME] => AFPV3G
[BigVALUE] => 25.00
[FAN_CMH] => 10000
[BigPEAK_POWER] => 6414.48
[Bigoutlet_velocity] => 7.02
[velocity_pressure] => 3.014
[Bigtotal_velocity] => 26.70
[SP1] => 3
[SP2] => 4
[SP3] => 5
[SP4] => 6
[SP5] => 7
[SP6] => 3
[SP7] => 2
[SP8] => 1
[SP9] => 2
[SP10] => 3
[Bigtotal_eff] => 0.62
[static_eff] => 0.55
[BigBKW] => 1.180
)
)
我必须在每个sp1到sp10的集合中找到最接近的数值[0] - > gt; STATIC_PRESSURE = 0.34, 阿雷[2] - →1 array [3] - > 23.依此类推.. 请帮我解决这个问题。
答案 0 :(得分:0)
这将搜索每个数组键中的最高值,名称为" SPx"其中x表示数字,也许你可以建立起来因为我不明白你的意思" STATIC_PRESSURE = 0.34,aray [2] - > 1 array [3] - > 23.依此类推。 "
$count = 0;
$max = array();
foreach ($array as $values) {
$max[$count] = 0;
foreach ($values as $key => $val) {
if(preg_match('/SP\d/', $key)===1){
if($val>$max[$count]){
$max[$count] = $val;
}
}
}
$count++;
}
var_dump($max);