Код: Выделить всё
Hello World
Код: Выделить всё
Hello World
Код: Выделить всё
function main()
{
$content = 'Hello World';
$html = str_get_html($content);
$html = htmlParser($html);
}
function htmlParser($html)
{
$supportedTags = ['div'];
foreach ($html->childNodes() as $node) {
// Remove unsupported tags
if (!in_array($node->tag, $supportedTags)) {
$node->parent()->innertext = str_replace($node->outertext, $node->innertext, $node->parent()->innertext);
$node->outertext = '';
}
if ($node->childNodes()) {
htmlParser($node);
}
}
return $html;
}
Код: Выделить всё
Hello World !![/b][b]
Код: Выделить всё
Hello World !![/b]
Код: Выделить всё
Hello World !!
Спасибо за детальное решение моей проблемы.
Подробнее здесь: https://stackoverflow.com/questions/520 ... e-html-dom