If you are tring to remove the script try this:
preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $data);
Question
I have the code like this:
$data='<p>text begin</p>
<script type="text/javascript">
$(".idr").hide();
$("[rel=tooltip]").tooltip({ placement: "top"});
</script>
<p>text finish</p>';
I'm trying to remove below text:
<script type="text/javascript">
$(".idr").hide();
$("[rel=tooltip]").tooltip({ placement: "top"});
</script>
with preg_replace()
echo preg_replace("/<script(.+?)script>/i", '', $data);
But it's doesn't work. Any suggestions?
Solution
If you are tring to remove the script try this:
preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $data);
OTHER TIPS
Just add multiline modifier:
echo preg_replace("/<script(.+?)script>/si", '', $data);
// here __^