Reputation: 10691
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 .
Upvotes: 2
Views: 1687
Reputation: 15699
Use a HTML DOM parser to get the text within the tags, and then run your str_replace() function on the result.
Upvotes: 2