PHP count()函數講解
來源:懂視網
責編:小采
時間:2020-11-27 14:43:33
PHP count()函數講解
PHP count()函數講解:PHP count() 函數 實例 計算 car 節點的子節點個數: <?php $xml=<<<XML <cars> <car name=Volvo> <child/> <child/> <child/> <child/> <
導讀PHP count()函數講解:PHP count() 函數 實例 計算 car 節點的子節點個數: <?php $xml=<<<XML <cars> <car name=Volvo> <child/> <child/> <child/> <child/> <
PHP count() 函數
實例
計算 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()
函數計算指定節點的子節點個數。
語法

總結
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
PHP count()函數講解
PHP count()函數講解:PHP count() 函數 實例 計算 car 節點的子節點個數: <?php $xml=<<<XML <cars> <car name=Volvo> <child/> <child/> <child/> <child/> <