Created
September 11, 2013 13:36
-
-
Save fabrizim/6523731 to your computer and use it in GitHub Desktop.
_inner_html replacement to work with < PHP 5.3.6
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
/** | |
* innerHTML style function | |
* | |
* @param DOMNode node | |
* @returns string the inner html string | |
*/ | |
protected function _inner_html( $node ) | |
{ | |
$doc = new DOMDocument('1.0','utf-8'); | |
$doc->formatOutput = true; | |
$copy = $doc->importNode( $node, true ); | |
$doc->appendChild( $copy ); | |
$html = $doc->saveHTML(); | |
$start = stripos($html, '>')+1; | |
return substr( $html, $start, strrpos($html, '<')-$start-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment