I have no idea how to explain this so forgive me for the title and description ahead of time. If you can figure this out you can translate anything.
The code below takes a string and breaks it up into "whole word" lines at the 143 character mark. This part works perfectly:
// Wrap at 143 characters
$x = 143;
$longString = 'This is a very long string. This is a very long string to be broken into separate lines to be worked with invidually.';
$lines = explode("\n", wordwrap($longString, $x));
echo $lines[0];
echo $lines[1]; etc. etc.
What I need to do next is "reassemble" the lines using Imagemagick to output the lines into a paragraph with spacing between lines.
Here is an example of ImageMagick's command line.
-background none -fill white -font Arial -pointsize 42 -size 2600x
caption:'{$textstring}' -geometry +830+3643 -composite
What I do not understand is how to loop through that array (i believe this is the term?) and add each new line generated until the array is complete (again not sure on term).
Basically, I don't know how many of these will be output.
echo $lines[0];
echo $lines[1];
etc.
and finally I will need to increase the geometry by X number of pixels each pass through the loop. So the geometry part would be -geometry +830+3643
then -geometry +830+3743
etc. every 100px.