Nevermind,
I got it :-)

I used:


function wraptext($text,$warp) {
    $text = explode(" ", $text);
    $i = 0; $length = 0;
        while ($i <= count($text)) {
            $length += strlen($text[$i]);
                 if ($length <= $warp) {
                    $output .= $text[$i]." ";
                    $i++;
                } else {
                    $output .= "\n";
                    $length = 0;
                }
        }
    return $output;
}


Then in the php file:

  echo (wraptext($row[0],80));



I'm learning :-)






  ----- Original Message ----- 
  From: Clayton Dukes 
  To: [EMAIL PROTECTED] 
  Sent: Monday, February 26, 2001 9:59 PM
  Subject: [PHP] How to wrap output of formatted text


  Hi all,

  how can I tell the output from a mysql query to wrap the cols at 80 (or whatever)?

  here's what I have:

  $row = mysql_fetch_array($sth);

    if ($row[0] != "") {
        echo $row[0];

  prints the data, but some of the results are long strings of text that don't wrap in 
the browser, how can I force them to wrap at the edge of the browser?



  Thanks,
  Clayton Dukes



------------------------------------------------------------------------------


  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to