function format_text($a, $b) // $a is text to format, from textarea, $b is line length { $line = array(); $limit = (strlen($a)/$b); for($i = 0; $i < $limit; $i++) { $start = $i*$b; $stop = (($i*$b) + $b) - 1; print "start : $start stop : $stop<br>"; array_push($line, substr($a, $start, $stop)); // separate into lines not greater than $b length } return $line; }
You made a minor mistake:) substr takes length as its third parameter, not stop. Here is the prototype of substr(): string *substr* ( string string, int start [, int length] ),