Text from Db does not wrap in Firefox/Mozilla

Discussion in 'PHP' started by livingearth, Mar 9, 2007.

  1. #1
    I am having problems getting text strings from a Db to wrap to the table cell if Firefox. It just continues out across the page as if a table cell weren't even there. I tried passing the string thru wordwrap() but it did nothing, is anyone familiar with how this is done?...
     
    livingearth, Mar 9, 2007 IP
  2. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You're probably looking for the nl2br function. That assumes that your DB data just has new line characters as opposed to the <br /> type code required in HTML.
     
    TwistMyArm, Mar 9, 2007 IP
  3. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Hi,

    have you try this one.

    <?php
    $text = "The quick brown fox jumped over the lazy dog.";
    $newtext = wordwrap($text, 20, "<br />\n");

    echo $newtext;
    ?>

    http://www.php.net/manual/en/function.wordwrap.php

    Example 2374. wordwrap() example

    Thanks,

    Mike


     
    gigamike, Mar 9, 2007 IP
    livingearth likes this.
  4. livingearth

    livingearth Well-Known Member

    Messages:
    1,469
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    140
    #4
    @ Gigamike
    That made some leeway only now it seems I need to parse for the hrefs. So it doesn't break the code when it breaks inside an href.. Any idea how to do this?
     
    livingearth, Mar 9, 2007 IP