SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing ending breaks

    I'm using an editor that has a little flaw, it adds up to one or two <br />'s which every it feels like at the time at the end of every submission. How can I go about removing all of the extra breaks at the end and just the end? I thought trim would work, but doesn't seem to.

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $trimmed rtrim$text_to_trim"<br />"); 
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, only seems to remove one at the most.

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $test "Hello World this is my sentence. <br /><br />";
    $trimmed rtrim$test "<br />");
    echo 
    $trimmed
    Hmmm produces : Hello World this is my sentence.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very weird I did a test too and it worked with normal data. But the $_POST data coming from spaw editor has random <br />'s at the end. But running rtrim on it seems to not work, I still have the breaks at the end.
    PHP Code:
    $body trim(rtrim($_POST['blog'], '<br />')); 

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Show me your code, I can assure you this function will strip all the "<br />"'s you can cram on the end of a line of text. Take your post data and paste it into my example, Echo the string before and after. Show me... Post me the data from $_POST['blog']......
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


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
  •