php8.5
Home/ Manual/ dom / domelement/ DOMElement::after

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::after
  • DOMElement::before

Source: reference/dom/domelement/after.xml · from the official PHP manual (php/doc-en)