note 10940 deleted from function.chunk-split by jimw

From: Date: Wed, 02 Jan 2002 12:26:32 +0000
Subject: note 10940 deleted from function.chunk-split by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-24280@lists.php.net to get a copy of this message
if you don't want to do the linebreak within a word, you can't use chunk_split but have to use a work-around like this: function linesize ($in, $size){ // this function formats lines according to the defined // linesize. Linebrakes (\n) are added when neccessary, // but only between words. $temptext=""; $temparray = explode (" ",$in); $i = 0; while ($i <= count($temparray)) { while ((strlen($temptext." ".$temparray[$i]) < $size) && ($i <= count($temparray))) { $temptext = $temptext." ".$temparray[$i]; $i++; } $out=$out."\n".$temptext; $temptext = $temparray[$i]; $i++; } return $out; }

« previous php.notes (#24280) next »