Hello!
I have a lot of html-pages in which the code is Google analytics, it is written differently, then with spaces and tabs, footnotes and other characters, in general, in different ways.
How can I remove this code using php?
Let's start with the fact that we open
$file = file_get_contents('index.html');
I tried through the regulars http://regex101.com/, but for some reason it does not work out to correctly compose and select an expression.
Example code to remove:
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-********']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();</script>
Help solve the issue. Thank!