Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
echo $xml->SLOT1->Effect; echo $xml->SLOT2->Effect; echo $xml->SLOT3->Effect;
有没有办法通过使用for循环来简化这个?我试过了,但它没有回应:
for
for ($x = 1; $x <= 3; $x++) { echo $xml->SLOT[$x]->Effect; }
您可以使用
$xml->{"SLOT".$x}->Effect;
for ($x = 1; $x <= 3; $x++) { echo $xml->{SLOT.$x}->Effect; }