Dada una cadena así formada:
hello Rose <tag> Micheal </tag> and <tag> July </tag> John. Quiero eliminar todo entre <tag> y </tag> y tener en la salida:
hello Rose and John.como puedo
Supongo que puedes usar:
$new_html = preg_replace('%<tag>.*?</tag> ?%si', '', $old_html);Si no desea usar DOM , siempre puede usar preg_replace para hacer esto.
$content = 'hello Rose <tag> Micheal </tag> and <tag> July </tag> John.'; $content = preg_replace('/<tag>[^<]+<\/tag>/i', '', $content); print $content; // returns: hello Rose and John.