Modern DOM library written in PHP for HTML documents
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.2 KiB

title
ContainerNode::insertBefore

ContainerNode::insertBefore — Adds a new child before a reference node

Description

public ContainerNode::insertBefore ( \DOMNode $node , \DOMNode|null $child = null ) : \DOMNode|false

This function inserts a new node right before the reference node. If you plan to do further modifications on the appended child you must use the returned node.

When using an existing node it will be moved.

Warning Only the following element types may be appended to any node using Node and subject to hierarchy restrictions depending on the type of node being appended to:

Note that \DOMAttr is missing from this list.

Parameters

node
The new node.
child
The reference node. If not supplied, node is appended to the children.