Skip to content

Instantly share code, notes, and snippets.

@fabrizim
Created September 11, 2013 13:36
Show Gist options
  • Save fabrizim/6523731 to your computer and use it in GitHub Desktop.
Save fabrizim/6523731 to your computer and use it in GitHub Desktop.
_inner_html replacement to work with < PHP 5.3.6
/**
* 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