#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    120
    Rep Power
    1

    Remove line breaks when echoing


    Hey, I have data in my db that has line breaks. I would like to echo this data out on a page and hide or remove the line breaks just within the echo. No clue how to go about this and Google was no help but if anyone here could help me with this, that would be great! Thanks for your time.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    26
    Do you mean the text has "<br/>" in it? Or it has newline characters (\n) in it?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    120
    Rep Power
    1
    <br />
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    26
    Couldn't you simply use str_replace()
    PHP Code:
    $stuff str_replace("<br/>"""$stuff); 
    If all the tags aren't exactly the same, but there aren't too many variations, you can just list the variations as an array in the first argument
    PHP Code:
    $stuff str_replace(array("<br/>""<br />""<br>""</br>"), ""$stuff); 
    Otherwise you might be straying into regex territory... hopefully not, though
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    120
    Rep Power
    1
    Ok what is the second parameter supposed to be in the str_replace('<br />', 'this parameter here', $stuff). Thanks again
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    26
    I don't mean to be a troll but you're aware there is a full manual online, right?

    http://php.net/str_replace
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    120
    Rep Power
    1
    Ya I know but i find it hard sometimes to understand what the manual tries to say about parameters and stuff, I ended up just putting, str_replace('<br />', '', $stuff); and that worked fine. Thanks again!

IMN logo majestic logo threadwatch logo seochat tools logo