I've got a string :
$source = '&
<script type="text/javascript">&</script>
&
<script type="text/javascript">&</script>
&';
The desired result is :
&
<script type="text/javascript">&</script>
&
<script type="text/javascript">&</script>
&
I try with :
echo preg_replace("#&(?!amp;)(?!<\/script>)(?![^<]script.*?>)#i",
"&", $source);
But I can only replace the first "&" or they are all replaced.
How can I get this result ?
Edit 1 :
Now if I've got a string :
$source = '&
<script type="text/javascript">text&text</script>
&
<script type="text/javascript">&</script>
&';
The desired result is :
&
<script type="text/javascript">text&text</script>
&
<script type="text/javascript">&</script>
&