note 41083 deleted from control-structures.do.while by nlopess
| From: | nlopess@php.net | Date: | Fri, 09 Jul 2004 15:56:35 +0000 |
| Subject: | note 41083 deleted from control-structures.do.while by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72925@lists.php.net to get a copy of this message | ||
Note Submitter: lucas@syslucas.com
----
function str_split($str,$num = '1') {
if($num < 1) return FALSE;
$arr = array();
for ($j = 0; $j < strlen($str); $j= $j+$num) {
$h=0;
if (substr($str,$h+$j+$num,1) != " ")
{
do{
$h+=1;
if (($h+$j+$num) > strlen($str))
{
break;
}
} while(substr($str,$h+$j+$num,1) != " ");
}
$arr[] = substr($str,$j,$num+$h);
$j+=$h;
}
return implode("<BR>",$arr);
}
//// Example ////
echo str_split ("Hello World!!! Good Morning.. This is Good",10);
//// Results ///
Hello World!!!
Good Morning..
This is Good