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

    Join Date
    Aug 2012
    Posts
    32
    Rep Power
    3

    Clean and keep line breaks


    Hello,

    I want to keep line spaces in comments but clean more then 2 after each.

    Example:

    $sentence="This is my first sentence
    This will be in a new row
    This will be too in a new row but not separated with 3line breaks just with

    one

    ";
    And i want to output just this:

    $sentence="This is my first sentence
    This will be in a new row

    This will be too in a new row but not separated with 3line breaks just with
    one
    ";
    Please Help

    Thanks in Advance
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,295
    Rep Power
    9400
    Why are there two newlines after "This will be in a new row"?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    78
    Rep Power
    0
    I want to keep line spaces in comments but clean more then 2 after each.
    what is a "line space"? seriously...

    cr vs newline? learn something about text formatting?

    I can't help you becoz:

    no clue what you 'really' want?.... and even if I did, I speak twerpy nerd, which does not include "line spaces"? baffling! I'll update the wiki, and run some regex tests.....
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,295
    Rep Power
    9400
    Ugh.
    Originally Posted by Arugula905
    what is a "line space"? seriously...
    Newlines. You couldn't tell?

    Originally Posted by Arugula905
    cr vs newline? learn something about text formatting?
    A CR is a newline.

    Originally Posted by Arugula905
    even if I did, I speak twerpy nerd,
    I don't know about the "nerd" part.
  8. #5
  9. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,184
    Rep Power
    492
    Originally Posted by AimyThomas
    I want to keep line spaces in comments but clean more then 2 after each.
    Hi,
    I don't know why or how but I think this makes sense to me (OMG HELP ME!) ... it all depends on how your user is entering the comments, if they enter into a HTML Textarea then when you save that into the database, the newlines should be retained when you echo their comments back to screen; you can then add either "<br /><br />" or "\n\n" to the end of the echo statement to make two line spaces afterwards.

    Also, LOL, I love your sticky about enclosing code in 'php' tags and yet, you didn't do it yourself :S

    Anyway, I think, if I understand your warblings correctly, that this is what you're after:-

    PHP Code:
    $sentence="This is my first sentence\n
    This will be in a new row\n
    This will be too in a new row but not separated with 3line breaks just with\n
    \n
    one\n
    \n
    "

    Of course, this is just a guess so forgive me if I am barking up the wrong tree here.
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    78
    Rep Power
    0
    Ugh. A CR is a newline.

    please share "line spaces"?

    Comments on this post

    • requinix agrees : newline + whitespace = line space
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    78
    Rep Power
    0
    white space is the bose-higgins particle

IMN logo majestic logo threadwatch logo seochat tools logo