Results 1 to 4 of 4

Thread: [RESOLVED] Removing html function

  1. #1
    Join Date
    May 2007

    resolved [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:

    PHP Code:
    function removeHTML($var1){
    $string preg_replace('/\s*\<[^)]*\>/'''$var1);

    Any ideas?

  2. #2
    Join Date
    Jul 2010
    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 &lt; 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.

  3. #3
    Join Date
    Nov 2002
    Baltimore, Maryland
    “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

  4. #4
    Join Date
    May 2007
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles