我有这段代码,它正在工作......我正在尝试这样做:
Array
(
[servicio_id 1] => Array
(
[peticion_id 1] => Array
(...)
[peticion_id 2] => Array
(...)
[peticion_id 3] => Array
(...)
)
[servicio_id 2] => Array
(
[peticion_id 1] => Array
(...)
[peticion_id 2] => Array
(...)
[peticion_id 3] => Array
(...)
)
)
所以每个 [servicio_id] 都有它自己的值 [peticion_id] ...问题是我的代码实际上在每个 [peticion_id] 数组中设置了相同的值,只要循环正在运行就增加它的大小...任何建议[servicio_id] 完成后如何清除并重新启动 [peticion_id] 数组?
谢谢你的建议
while($row = sqlsrv_fetch_array($sqlQuery)) {
if($row['peticion_id'] == 0) {
$ok[] = round($row['valor'], 3);
if($row['media_ok'] == null) {
$medias_ok = array("0", "0", "0", "0");
} else {
$medias_ok = Umbrales::getValues($row['media_ok'], $row['media']);
}
$max_ok[] = $medias_ok[1];
$min_ok[] = $medias_ok[0];
}
if($row['peticion_id'] == 1) {
$ko[] = round($row['valor'], 3);
if($row['media_ok'] == null) {
$medias_ko = array("0", "0", "0", "0");
} else {
$medias_ko = Umbrales::getValues($row['media_ok'], $row['media']);
}
$max_ko[] = $medias_ko[2];
}
if($row['peticion_id'] == 2) {
$rt[] = round($row['valor'], 3);
if($row['media_ok'] == null) {
$medias_rt = array("0", "0", "0", "0");
} else {
$medias_rt = Umbrales::getValues($row['media_ok'], $row['media']);
}
$max_rt[] = $medias_rt[3];
}
$datos[$servicios[$row['servicio_id']]] = array(
"OK" => $ok,
"KO" => $ko,
"RT" => $rt,
"UMBRAL_MIN_OK" => $min_ok,
"UMBRAL_MAX_OK" => $max_ok,
"UMBRAL_MAX_KO" => $max_ko,
"UMBRAL_MAX_RT" => $max_rt
);
}