1 回答

TA貢獻1725條經驗 獲得超8個贊
我通過前面提到的JS方法進行了修復。我得到了用戶以JS var形式生成的屬性數量,并以hidden inputde形式傳遞給PHP文件。在PHP文件中,我將此值用作范圍進行迭代。在下一次迭代中,我獲得了上一次迭代的最后一個值,以定義新的起始范圍。
if (isset($lastValue)) {
foreach (range($lastValue+1, $lastValue+$classNumber[$x]) as $indexValue) {
$key2 = array_search($indexValue, $attrValue);
echo "____Nome da Classe " . $value2 . " | Nome do atributo: " . $attrName[$key] . " | Valor do Atributo: " . $attrValue[$indexValue] . " | Cor do Atributo: " . $color[$indexValue] . "<br>";
}
$lastValue = $lastValue+$classNumber[$x];
} else {
foreach (range(0, $classNumber[$x]-1) as $indexValue) {
$key2 = array_search($indexValue, $attrValue);
echo "____Nome da Classe " . $value2 . " | Nome do atributo: " . $attrName[$key] . " | Valor do Atributo: " . $attrValue[$indexValue] . " | Cor do Atributo: " . $color[$indexValue] . "<br>";
}
$lastValue = $classNumber[$x]-1;
}
$x++;
添加回答
舉報