note 13357 deleted from function.wordwrap by jimw
| From: | jimw@php.net | Date: | Fri, 14 Dec 2001 20:39:26 +0000 |
| Subject: | note 13357 deleted from function.wordwrap by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22773@lists.php.net to get a copy of this message | ||
I've had problems using wordwrap, so I made this function which wraps the string at the given
lenght and puts the chunks in an array
function mywrap($str,$len,$arr) {
$slen=strlen($str);
for ( $i=0 ; $i<= (ceil($slen/$len)-1) ; $i++ ) {
$arr[$i]=substr($str,($len*$i),$len);
}
return $arr;
}
Example:
$cunks=mywrap("thereyougo!",2,$new);
print_r($chunks);
will return
Array ( [0] => th
[1] => er
[2] => ey
[3] => ou
[4] => go
[5] => !
)
..and there you go