标签:style translate XML 运行 count() sim news abs printf
计算 car 节点的子节点个数:
<?php $xml=<<<XML <cars> <car name="Volvo"> <child/> <child/> <child/> <child/> </car> <car name="BMW"> <child/> <child/> </car> </cars> XML; $elem=new SimpleXMLElement($xml); foreach ($elem as $car) { printf("%s has %d children.<br>", $car[‘name‘], $car->count()); } ?>
运行实例 »
count() 函数计算指定节点的子节点个数。
标签:style translate XML 运行 count() sim news abs printf
原文地址:https://www.cnblogs.com/furuihua/p/11743676.html