PHP String Replace between two html tags
问题 I am trying to replace text between two tags in a html document. I want to replace any text that isn't enclosed with a < and >. I want to use str_replace to do this. php $string = '<html><h1> some text i want to replace</h1><p>some stuff i want to replace </p>'; $text_to_echo = str_replace("Bla","Da",$String); echo $text_to_echo; 回答1: Try this: <?php $string = '<html><h1> some text i want to replace</h1><p> some stuff i want to replace </p>'; $text_to_echo = preg_replace_callback( "/(<([^.]+)