I have these imaginary strings:
$txts=
array('<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>',
'<script>document.getElementById("demo").innerHTML = "Hello JavaScript!";</script>',
'document.getElementById("demo").innerHTML = "Hello JavaScript!";');
Now I would like an elegant simple solution to check if the <script> and </script> tags are surrounding the string and if not, surround the string with those tags.
So, $txts[0] and $txts[1] are valid but $txt[2] should be surrounded with <script> </script>
I have a couple of solutions in my head but none 'sits' right with me, they are over complex or not clean.
Can you come up with a proper solution?