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 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    70
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Stop <br> From Echoing In Text Field

    Need Help

    Starting a break like this But when it posts threw to the database it only displays <br/> in the text field/when a user edits the data/info like posts in a text field.
    im using nl2br function in like this nl2br($_POST['value']);
    how can i stop the <br/> from echoing?? like Vbulletin (this forums software) And other sites..
    Ive looked all over google still stumbed!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,497
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You are doing "nl2br" (new line to br), which is fine.

    There is no command to do "br2nl" (the revserse), so use a function ...

    PHP Code:
    <?php

    $textarea
    =br2nl($text);
    echo 
    $textarea;

    // <br> or <br /> to nl function
    function br2nl($str) { 
    return 
    preg_replace('=<br */?>=i'""$str); 


    ?>


  •  

    Posting Permissions

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