我有一组带有特定ID的XML属性来分隔他们的子内容,如下所示:
<attribute id="1">
<childattribute1></childattribute1>
<childattribute2></childattribute2>
</attribute>
<attribute id="2">
<childattribute1></childattribute1>
<childattribute2></childattribute2>
</attribute>
ID变量匹配一个URL参数,我正在抓取并存储为这样的变量:
$franchiseID = $_GET['franchise'];
结果只是一个匹配的数字,例如:
$franchiseID = 1 (or 2, or 3, or whatever)
我正在尝试在echo调用中使用该变量,因此只调用具有该特定ID的parent属性的子属性:
<?php echo $franchise->popups->franchisepop->franchiseTitle[$franchiseID]->franchisetitle ?>
但这不起作用。使用这样的变量的正确语法是什么?