I have for example this code that removes all DIVs
that contains the contextual
class from my HTML
code passed in the string $sHTML
:
$nPosIni = strpos($sHTML, '<div class="contextual">');
while ($nPosIni > 0) { // remove todas as divs com a classe contextual
$nPosFim = strpos($sHTML, '</div>', $nPosIni);
$sHTML = substr($sHTML, 0, $nPosIni) .
substr($sHTML, ($nPosFim + strlen("</div>")));
$nPosIni = strpos($sHTML, '<div class="contextual">');
}
So, what I need is to remove from a code HTML
another <div>
with another class, however I want it to remain only a <h3> CONTEÚDO </h3>
that has within that <div>
.
I tried in many ways but could not find an efficient way, does anyone know of any good practice?
NOTE: The code I am using does not accept scripts or functions, only PHP
, HTML
and CSS
...
EXAMPLE HTML:
<html>
<head></head>
<body>
<div class="xy">
<h3> conteúdo </h3>
</div>
</body>
</html>
HTML HOW TO STAY:
<html>
<head></head>
<body>
<h3> conteúdo </h3>
</body>
</html>