note 74553 deleted from function.explode by bjori
| From: | bjori@php.net | Date: | Tue, 17 Apr 2007 09:27:14 +0000 |
| Subject: | note 74553 deleted from function.explode by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125496@lists.php.net to get a copy of this message | ||
Note Submitter: orenivr at gmail dot com
----
The function bellow split paragraph to several lines
Oren Wisman
<?php
function paragraphsplit($str,$lensize=24)
{
$words=explode(" ",$str);
$paragraph=array();
$ib=0;
for($i=0;$i<=count($words);$i++)
{
if (strlen($paragraph[$ib].$words[$i])>$lensize) $ib++;
$paragraph[$ib]=$paragraph[$ib]." ".$words[$i] ;
}
return $paragraph;
}
$message="simple function to remove words if more than max allowed words or add a charcter
";
$paragraph=paragraphsplit($message) ;
for($i=0;$i<count($paragraph);$i++)
{
echo "{$paragraph[$i]}<br>";
}
?>