Question

I have a variable like

$content = "Lorem Ipsum is simply <b>dummy text of the printing</b> and typesetting industry.
 Lorem Ipsum has been the industry's <i>standard dummy text</i> ever since the 1500s 
<string>javascriptFunc();</script>" ;

when i use str_replace('a', '', $content); all the 'a's get removed. But the 'a's within the <script> tag should not be removed.

or is there any way to replace text other than this method

Please help .

Was it helpful?

Solution

Use a HTML DOM parser to get the text within the tags, and then run your str_replace() function on the result.

OTHER TIPS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top