DOMElement::after
PHP function
Edit on GitHub ✎
(PHP 8)
Adds nodes after the element
Description
DOMElement::after(DOMNode|string ...$nodes): void
Adds the passed nodes after the element.
Examples
DOMElement::after example
Adds nodes after the hello element.
php
<?php
$doc = new DOMDocument;
$doc->loadXML("<hello/>");
$container = $doc->documentElement;
$container->after("beautiful", $doc->createElement("world"));
echo $doc->saveXML();
?>The above example will output:
output
<?xml version="1.0"?>
<hello/>
beautiful
<world/>See Also
DOMChildNode::afterDOMElement::before