PHP တွင်Children() လုပ်ဆောင်ချက်
ဥပမာ
လက်ရှိဒြပ်စင်တွင် ကလေးများ ရှိ၊ မရှိ စစ်ဆေးပါ။ လက်ရှိဒြပ်စင်ကိုထုတ်ပါ-
<?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()
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | လက်ရှိဒြပ်စင်တွင် ကလေးများရှိလျှင် မှန်ကန်ပါသည်။ မဟုတ်ရင် မှားမယ်။ |
---|---|
PHP ဗားရှင်း- | 5.0+ |
❮ PHP SimpleXML အကိုးအကား