本文整理匯總了PHP中DOMElement::hasChildren方法的典型用法代碼示例。如果您正苦於以下問題:PHP DOMElement::hasChildren方法的具體用法?PHP DOMElement::hasChildren怎麽用?PHP DOMElement::hasChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DOMElement
的用法示例。
在下文中一共展示了DOMElement::hasChildren方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: structHandlerParagraph
/**
* structHandlerParagraph (Structure handler, pass 2 after childre tags)
* Structure handler for paragraph tag.
*
* @param DOMElement $element
* @param DOMElement $newParent node that are going to become new parent.
* @return array changes structure if it contains 'result' key
*/
function structHandlerParagraph($element, $newParent)
{
$ret = array();
if ($element->getAttribute('ezparser-new-element') === 'true' && !$element->hasChildren()) {
$element = $element->parentNode->removeChild($element);
return $ret;
}
// Removes single line tag
$line = $element->lastChild;
if ($element->childNodes->length == 1 && $line->nodeName === 'line') {
$lineChildren = array();
$lineChildNodes = $line->childNodes;
foreach ($lineChildNodes as $lineChildNode) {
$lineChildren[] = $lineChildNode;
}
$line = $element->removeChild($line);
foreach ($lineChildren as $lineChild) {
$element->appendChild($lineChild);
}
}
return $ret;
}