Wordwrap doesn't seem to work with new line?

Discussion in 'PHP' started by Silver89, Sep 4, 2009.

  1. #1
    Hi,

    I'm trying to do the following:

    
    <?=wordwrap($text, 20, "\n", true);?>
    
    PHP:
    But it has no effect on the text?

    If I replace the \n with <br /> it works but this messes up the code in the text.

    Could anyone plase advise on this issue?

    Thanks
     
    Silver89, Sep 4, 2009 IP
  2. Martinoes

    Martinoes Peon

    Messages:
    110
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This works.

    <?php
    $text = "bla bla bla bla bla bla blaadsfadsfadadsfdsafdsafsfdsaf bla bla bla bla bla";
    
    $text = wordwrap($text, 20, "\n", true);
    
    echo '<pre>';
    echo $text;
    echo '</pre>';
    ?>
    PHP:
     
    Martinoes, Sep 5, 2009 IP
    Silver89 likes this.
  3. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #3
    Thanks that worked,

    Realised after that line breaks just put a line brake into the html and it doesn't show up on screen.
     
    Silver89, Sep 5, 2009 IP