-2

Hi i have a code here which previously works. it gets text input and prints the input using imagettftext on a jpg. i used word wrap and explode to assign where the text should appear. I have seen other post almost similar to this but i dont want to use for loops and counters or things as such. what do you think im doing wrong with my code? it previously works fine but now it's not working. thanks in advance for any help. here's my code. please feel free to edit it.

$story = "My story begins with " . $_POST['story'];

$newtext = wordwrap($story, 35, "\n", true);
$newertext = explode("\n", $newtext);
imagettftext($im, 8, 0, 280, 386, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 398, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 410, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 422, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 434, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 446, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 458, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 470, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 482, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 494, $black, $font2, $newertext);
imagettftext($im, 8, 0, 280, 506, $black, $font2, $newertext);
Jben Kaye
  • 171
  • 1
  • 5
  • 16

1 Answers1

0

explode returns an array, please check on how arrays are accessed in PHP.

$story = "My story begins with " . $_POST['story'];

$newtext = wordwrap($story, 35, "\n", true);
$newertext = explode("\n", $newtext);
imagettftext($im, 8, 0, 280, 386, $black, $font2, $newertext[0]);
imagettftext($im, 8, 0, 280, 398, $black, $font2, $newertext[1]);
imagettftext($im, 8, 0, 280, 410, $black, $font2, $newertext[2]);

etc

jdog
  • 2,465
  • 6
  • 40
  • 74
  • Hi @jdog thank you for your answer. Now it's working. I have edited my quetion so it would be more useful for others. thanks again :) – Jben Kaye Oct 29 '13 at 06:55