Re: How to wrap output of formatted text
| From: | Clayton Dukes | Date: | Tue, 27 Feb 2001 03:22:39 +0000 |
| Subject: | Re: How to wrap output of formatted text | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41784@lists.php.net to get a copy of this message | ||
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: php-general@lists.php.net
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: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net