[RESOLVED] Removing html function
I've been using a function to remove any content between < > brackets, however it seems to not be working correctly.
Here is the function, i'm not very good with regular expressions - (it was modified, from a function which removes () brackets.)
Here is the function:
$string = preg_replace('/\s*\<[^)]*\>/', '', $var1);
preg_replace has a limit on how much data it can handle. I'm not sure what the limit is, but I don't think it can handle a 400 page novel.
My 2nd suggestion is to map the characters into a character map, then return them encoded as html entities. I'm assuming this is for a form submission. So when someone submits "<script src="haxx.com/sesshijack.js>", it comes back exactly how it came in, accept the < is a < etc etc.
That's how these forums (may) work. You can also build an array of each character you want taken out (its not as flexible as regex) and just loop through it with str_replace, or remove the html completely.
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
—Tim Berners-Lee, W3C Director and inventor of the World Wide Web
Thanks Charles, that was exactly what i was looking for.
The reason it was needed was to remove potential links/images etc from blog feed summaries.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)