SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast vek's Avatar
    Join Date
    Jun 2004
    Location
    Florence, KY
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question add spaces after < for non html tags?

    i'm trying to search through a string and put a space after every "<" that is found and boarders text that is not an html tag.

  2. #2
    SitePoint Evangelist
    Join Date
    Dec 2000
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So do you want it to output < to the browser? If so, then do a find/replace string (I don't remember it off hand...I'll try searching, but I know that somebody will beat me to it) and find all the and replace them with &lt; . Make sense?
    Corbb O'Connor
    Looking for quality website design or database programming?
    Contact me for more information and a FREE quote!

  3. #3
    Romans 12:2 codyrockx's Avatar
    Join Date
    Jul 2003
    Location
    Newberg, Oregon
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe
    PHP Code:
    str_replace('<','&lt;',$string); 
    Codyrobert.com - Designer and Developer

  4. #4
    SitePoint Evangelist
    Join Date
    Dec 2000
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See? I knew somebody would get it! But he wants a space..so it should be:
    PHP Code:
    str_replace('<','&lt; ',$string); 
    But what if he wants to do it so that if it's a legitimate HTML tag, then ignore it. But if it's not an HTML tag, then replace it? Like say there's <a href...> then it would not replace it with &lt; . But say you have <just=....> then it would replace it with &lt;just=....> How would you do that?
    Corbb O'Connor
    Looking for quality website design or database programming?
    Contact me for more information and a FREE quote!

  5. #5
    SitePoint Enthusiast vek's Avatar
    Join Date
    Jun 2004
    Location
    Florence, KY
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JustForWebmasters
    See? I knew somebody would get it! But he wants a space..so it should be:
    PHP Code:
    str_replace('<','&lt; ',$string); 
    But what if he wants to do it so that if it's a legitimate HTML tag, then ignore it. But if it's not an HTML tag, then replace it? Like say there's <a href...> then it would not replace it with &lt; . But say you have <just=....> then it would replace it with &lt;just=....> How would you do that?
    yea, i want to leave legit html tags alone.


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
  •