我有一个数组,它从一个xml文件中读取它的单元格,我写了“for”,但现在因为我不知道有多少个节点我想要写这个循环一种方式,它开始和结束了,结束的与XML file.my代码:如何使用循环阵列
$description=array();
for($i=0;$i<2;$i++)
{
$description[$i]=read_xml_node("dscription",$i);
}
和我的XML文件:
<eth0>
<description>WAN</description>
</eth0>
<eth1>
<description>LAN</description>
</eth1>
在此代码我必须知道“2”,但我想知道一种不需要知道“2”的方法。
什么XML解析器/ API您使用的? – deceze
这是使用SimpleXML很平凡:http://php.net/manual/en/simplexml.examples-basic.php – deceze
首先,PHP中没有本地函数称为'read_xml_node',所以你必须告诉我们它的代码或函数存在的库。其次,你拼写'描述'错误('dscription')。 – h2ooooooo