SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face Removing <br /> textarea default text

    I write user data to a file:

    $text = nl2br($_POST["text"]); // keeps new lines in text area
    $fp = fopen ("text.txt", "w+"); // "w" erases file
    fwrite ($fp,"$text");
    fclose ($fp);


    I then read the text from the file and insert it as textarea default text for the user to edit and resubmit:

    $f = "http://.../text.txt";
    $text = file_get_contents ("$f");
    $replace = '<br />';
    str_replace($replace,"",$text);

    echo'<form action="http://www.../filewriter.php" enctype="multipart/form-data" method=post>';
    echo "Horario / Schedule <br><textarea name=\"text\" rows=\"10\" cols=\"80\">";
    echo $text;
    echo "</textarea><input type=\"submit\" value=\"enviar / submit\">
    </form>";

    The problem is that the default text printed in the textarea still has the <br />.

    Any ideas on how to strip the unwanted line breaks out of the text?

    Thank you!
    There are no dead atheists.

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    str_replace returns the string changed, it does not affect the original string.

    PHP Code:
    $textstr_replace($replace,"",$text); 
    Saul

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That fixed it! Thanks...
    There are no dead atheists.


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
  •