- var_export: documentation ( source)
- preg_split: documentation ( source)
<?php
$html = <<<HTML
<p>Some content <a href="www.test.com">A link</a></p>
HTML;
var_export(preg_split('~\s+|(<[^>]+>)~', $html, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));