Click to See Complete Forum and Search --> : wordwrap() into an array


Doc Thirst
03-18-2008, 01:06 PM
OK I have this nasty paragraph of text that I need to wordwrap. However, I also need to determine if its the last line of the text or not (so I can add a 0 or 1 to the end), as well as append a string to the beginning (such as an id number).

So is there an method of writing each line of a wordwrap into an array or foreach statement rather then just spitting out the whole block of text?

Doc Thirst
03-18-2008, 01:25 PM
For the second time today, I figured it out before it could be commented on. I'm an idiot:

$wrapped = wordwrap($text, $width, $marker);
$lines = explode($marker, $wrapped);
foreach ($lines as $line_index=>$line)
{

add start and end here
}