PHP hasChildren()ฟังก์ชัน
ตัวอย่าง
ตรวจสอบว่าองค์ประกอบปัจจุบันมีลูกหรือไม่ หากมี ส่งออกองค์ประกอบปัจจุบัน:
<?php
$bookxml = <<<XML
<bookstore>
<book>
<title>Everyday Italian</title>
<author>Giada De
Laurentiis</author>
</book>
<book>
<title>Harry Potter</title>
<author>J K.
Rowling</author>
</book>
<book>
<title>Learning XML</title>
<author>Erik T. Ray</author>
</book>
</bookstore>
XML;
$xml = new SimpleXMLIterator($bookxml);
for( $xml->rewind(); $xml->valid(); $xml->next() ) {
if($xml->hasChildren())
{
var_dump($xml->current());
echo
"<br>";
}
}
?>
ความหมายและการใช้งาน
ฟังก์ชัน hasChildren() ตรวจสอบว่าองค์ประกอบปัจจุบันมีลูกหรือไม่
ไวยากรณ์
SimpleXMLIterator::hasChildren()
รายละเอียดทางเทคนิค
คืนมูลค่า: | TRUE หากองค์ประกอบปัจจุบันมีลูก เท็จ มิฉะนั้น |
---|---|
รุ่น PHP: | 5.0+ |
❮ การอ้างอิง PHP SimpleXML