note 17279 deleted from function.wordwrap by jimw

From: Date: Fri, 14 Dec 2001 20:40:09 +0000
Subject: note 17279 deleted from function.wordwrap by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22779@lists.php.net to get a copy of this message
I tried some of the functions above to have a workaround for wordwrap on php 4.01 somehow they all didn`t do what I thought a wordwrap for "germans" ;) should do. Maybe this solution isn`t the fastest but ... working properly. //----- function mb_wordwrap($str,$width=140) { $elements=preg_split("/[\040\240\254\255]/",$str); $i=0;$a=0;$out=''; foreach($elements AS $key => $val) { if(strlen($val)+@strlen(@$row)>$width) { $pos[]=$key; unset($row); } @$row.=$val; $i++; } foreach($pos AS $key) { for(;$a<$key;$a++) { $out.=' '.$elements[$a]; } $out.="\n"; $a=$key; } for($b=$key;$b<$i;$b++) { $out.=' '.$elements[$b]; } return $out; }

« previous php.notes (#22779) next »