Last active
February 16, 2020 11:48
-
-
Save lucymtc/ef2d49da719d6157847f3a4d3b98bfa2 to your computer and use it in GitHub Desktop.
helper DOMNode::insertAfter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Helper function to insert node after another node. | |
| * | |
| * @param DOMNode $newNode Node to be appended. | |
| * @param DOMNode $refNode Node required to have new node appended after it. | |
| */ | |
| function insertAfter ( $newNode, $refNode ) { | |
| if( $refNode->nextSibling ){ | |
| $refNode->parentNode->insertBefore( $newNode, $refNode->nextSibling ); | |
| } else { | |
| $refNode->parentNode->appendChild( $newNode ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment