note 10183 added to wordwrap
| From: | john at defected dot net | Date: | Mon, 18 Dec 2000 06:08:28 +0000 |
| Subject: | note 10183 added to wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8832@lists.php.net to get a copy of this message | ||
This isn't really relevant to wordwrap() but it's a way I've come up with to
'break' at after a certain amount of characters.
<?php
$string_to_break = "This string will be broken";
if(strlen($string_to_break)>25)
{
$string = substr($string_to_break,0,24);
if($string != " ")
{
$last_space = strrpos($string, " ");
$string = substr($string_to_break,0,$last_space);
print($string."...");
} else {
print($string."...");
}
} else {
print($string_to_break);
}
?>
---
This will print:
This string will be...
http://www.php.net/manual/function.wordwrap.php