dane-m
11/29/2017 - 2:15 PM

Have to loop backward through the DOMnodeList to delete nodes

Have to loop backward through the DOMnodeList to delete nodes

	$comment_anchors = $dom_comment->getElementsByTagName( 'a' );

	for ( $i = $comment_anchors->length; --$i >=0; ) :
		$comment_anchor = $comment_anchors->item( $i );
		if ( trim ( $comment_anchor->nodeValue ) === '' ) :
			$comment_anchor->parentNode->removeChild( $comment_anchor );
		endif;
	endfor;