Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: str_replace

  1. #1
    New Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    str_replace

    Hi i used the <pre></pre> tags so when the user writes a blog and presses enter, it will create a break, however when they type and the text automaticaly goes under neith it counts it as one line whic streches the page.

    I have come up with this idea:
    PHP Code:
    <?php
     
    echo str_replace("<br>"," *SOMTHING HERE* ","$row['blog']");
     
    ?>
    also if thats right, what will go where SOMETHING HERE is and is the $row['blog'] correct.
    http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.

  • #2
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Hi there,

    Could you provide a little more info? I assume you are placing the data returned from the textarea of a posted form block within the pre tag ... in which case you don't have to do anything to the data.

  • #3
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    AFAIK you'd replace \n with <br>.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    In which case you should be using the nl2br function
    PHP Code:
    echo nl2br($row['blog']); 
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh thanks guys, i senn the nl2br but i didnt realies than nl was the space 2 was changeto and br obv the break
    http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.


  •  

    Posting Permissions

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