I am trying to take a user inputted mass of text, and strip out ONLY the following html tags:
1) <HTML...>
2)
3) <HEAD....</HEAD>
4) <BODY...>
6) </BODY>
7) <SCRIPT...</SCRIPT>
Thus leaving the 'middle' of an html page and still allowing html tags other than the ones above. strip_tags() is not a solution. Below is what I used with another language, but I cannot figure out why it wont work with PHP???
//lets get the data and mess with it, shall we?
$cleandesc = $description;
// kill the tags
$cleandesc = eregi_replace("/<html[^>]*>\s*\n*/i",'',$cleandesc);
$cleandesc = eregi_replace("/<\/html[^>]*>\s*\n*/i",'',$cleandesc);
// kill the <head> section
$cleandesc = eregi_replace("/<head>[\s\S]*<\/head>\s*\n*/i",'',$cleandesc);
$cleandesc = eregi_replace("/<head>[\s\S]*<\/HEAD>\s*\n*/i",'',$cleandesc);
// kill any <script> section
$cleandesc = st.replace("/<script[^>]*>[\s\S]*<\/script[^>]*>\n*/",'',$cleandesc);
// kill the body tags
$cleandesc = eregi_replace("/<body[^>]*>\s*\n*/i",'',$cleandesc);
$cleandesc = eregi_replace("/<\/body[^>]*>\s*\n*/i",'',$cleandesc);
// put back the modified data
$description = $cleandesc;
"nothing" changes... Not a single char in a sample imput. Bugs me out? I gots something wrong, but apparently its not something wrong enough to cause a parse error, as the script runs fine.
Any clues?