title: PHP Remove JavaScript
body: <p>I am trying to remove JavaScript from the HTML. </p>
  
  <p>I can't get the regular expression to work with PHP; it's giving me an null array.  Why?</p>
  
  <pre><code>&lt;?php
  $var = '
  &lt;script type="text/javascript"&gt; 
  function selectCode(a) 
  { 
     var e = a.parentNode.parentNode.getElementsByTagName(PRE)[0]; 
     if (window.getSelection) 
     { 
        var s = window.getSelection(); 
         if (s.setBaseAndExtent) 
        { 
           s.setBaseAndExtent(e, 0, e, e.innerText.length - 1); 
        } 
        else 
        { 
           var r = document.createRange(); 
           r.selectNodeContents(e); 
           s.removeAllRanges(); 
           s.addRange(r); 
        } 
     } 
     else if (document.getSelection) 
     { 
        var s = document.getSelection(); 
        var r = document.createRange(); 
        r.selectNodeContents(e); 
        s.removeAllRanges(); 
        s.addRange(r); 
     } 
     else if (document.selection) 
     { 
        var r = document.body.createTextRange(); 
        r.moveToElementText(e); 
        r.select(); 
     } 
  } 
  &lt;/script&gt;
  ';
  
     function remove_javascript($java){
     echo preg_replace('/&lt;script\b[^&gt;]*&gt;(.*?)&lt;\/script&gt;/i', "", $java);
  
     }    
  ?&gt;
  </code></pre>