Results 1 to 12 of 12

Thread: I get That php.net <pre>

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    I get That php.net <pre>

    Have you ever wanted to remove the '<br />' tags between
    '<pre>' and '</pre>' tags after a call to nl2br()? I just
    figured out how to do this and thought others would benefit.

    $html = preg_replace(
    "/(<pre>)([\w\W]*)(<\/pre>)/e",
    "'\\1'.str_replace('<br />','','\\2').'\\3'",
    $html);

    ___________
    I want to do same with <textarea> .. I try this code

    $html = preg_replace(
    "/(<textarea>)([\w\W]*)(<\/textarea>)/e",
    "'\\1'.str_replace('<br />','','\\2').'\\3'",
    $html);

    __________
    but it does not work ... Why ?

  2. #2
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    that is because you are a nim rod.....


    if you want to remove the <br> tags then just do htmlspecialchars()

    or something like that.

    textarea is a lot different then a <pre> tag. why are you even doing php because you apparently don't get it.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    Teaxarea

    please .. I want to remove <br> that beetwen <textarea> and </textarea>

    I try above code .. but for sorry does not work .. so can you tell me the right code,please?

  4. #4
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    Cant you just

    $text = str_replace("<br>","",$_REQUEST[textarea]);

  5. #5
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Originally posted by scoutt
    why are you even doing php because you apparently don't get it.
    scathing!

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    for one when you submit text from a text area there is no <br> tags in it unless you insert them your self through code.


    if you are doing this then just don't do it.

    come on

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    -

    I insert <br> by code because I want to use this code also with text :

    $html=str_replace("\r\n", " <BR> ",$html);

  8. #8
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    Sorry I have no clue what your doing now, you want it to add <br> then remove it again? what?

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    B

    because I have text contain from many line ! for example :
    ____________________
    do
    not
    forget
    to write this code

    [textarea]
    The
    Code
    Is
    Here
    [textarea]
    ___________________

    so I want replace new line with "<BR>" except new line that between [textarea] and [/textarea]

  10. #10
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    M.R scoutt

    That will not help me.

    please try to tell me what is the wrong in this code:

    $html = preg_replace(
    "/(<textarea> )([\w\W]*)(<\/textarea> )/e",
    "'\\1'.str_replace('<br />','','\\2').'\\3'",
    $html);


    Why it work with <pre> but does not work with <textarea> ?

  12. #12
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    listen and listen carefully.

    <pre> tag is not a form tag <textarea> is a form tag. you cannot get the stuff between <textarea>stuff</textarea> because there is nothing there. it is contained in a variable that is produced by name.

    <textarea name="something"></textarea>

    if you don't want no <br> in the textarea then don't putting any in.

    now you say you are using [textarea][/textarea] so which is it.

    if you are using [textarea] then YES that link will help you. if you are using str_replace() to take out all the \r\n then DON'T DO IT.

    why is this so hard.................

    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

Posting Permissions

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



Click Here to Expand Forum to Full Width