php strip_tags problem
I found that using php function, strip_tags, does not remove all the markup elements correctly from the subject content. First of all, if an anchor link includes a line break, it will not be removed correctly. Also, the style information is not properly removed as well. In the following script, I also added in the regex to remove any content in between script tags, but that may or may not be necessary.
function strip_all_tags($content)
{
$content = preg_replace('/\n/',' ',$content);
$content = preg_replace('/<script.*<\/script>/U',' ',$content);
$content = preg_replace('/<style.*<\/style>/U',' ',$content);
$content = strip_tags(strtolower($content));
return $content;
}
The function will remove all line breaks so strip_tags will not have problems with finding all markups. Since strip_tags does not remove <style> tags, the new function will remove them using regex.
Pages
Categories
- .net
- admin
- android
- apache
- asp.net
- benchmark
- Coding
- design
- domains
- E-commerce
- EC2
- GeoServer
- google maps
- hardware
- hosting
- Internet Marketing
- Just nonsense
- linux
- mobile
- MSSql
- mysql
- networking
- Open Source
- our development
- php
- privacy
- Search Engine
- seo
- server
- Software
- spam
- Sphinx
- ssl
- Startups
- System
- Tech Companies
- Technology Progress
- testing
- ubuntu
- Uncategorized
- VM
- Web Security
- web startup
- Website Content
- website speed
Blogroll
Archive
- March 2012
- February 2012
- December 2011
- November 2011
- October 2011
- June 2011
- April 2011
- March 2011
- February 2011
- September 2010
- August 2010
- July 2010
- April 2010
- January 2010
- December 2009
- October 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- January 2009
- December 2008
- November 2008
- October 2008
- July 2008
- June 2008
- May 2008
- February 2008
- October 2007
- September 2007
- August 2007
- May 2007
- January 2007
- November 2006
- October 2006
- August 2006
- June 2006
- April 2006
- March 2006
- December 2005
- November 2005
- October 2005
- September 2005