SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot dadofgage's Avatar
    Join Date
    Feb 2005
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    strip_tags not working

    I am using Drupal and have a view in drupal that shows search results.

    Part of the results is a description field that contains HTML code that is controlled by the user and I want to strip out that code from being visible in the search results.

    I am using:
    PHP Code:
    print strip_tags($description); 
    This shows what it currently looks like:


    Under normal circumstances, I would expect that this would work but for some reason is not stripping out the HTML - any thoughts on why this would be or how I can get it to work?

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It'll only strip out the tags, not the content within the tags. It's a simple algorithm that looks for a "<...>" pattern. If that's not the problem, perhaps your HTML is very malformed. It's hard to say without seeing the code.

  3. #3
    SitePoint Zealot dadofgage's Avatar
    Join Date
    Feb 2005
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am expecting it to strip out the <p>, <em> and others, but that is not happening.

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe because the string was already HTML escaped (i.e. ">" already converted to "&gt;")?


Bookmarks

Posting Permissions

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