1 回答

TA贡献1725条经验 获得超7个赞
我通过前面提到的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++;
添加回答
举报