doupijin0397 2013-10-29 05:49
浏览 52
已采纳

Imagettftext无法使用wordwrap / explode [关闭]

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, "
", true);
$newertext = explode("
", $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);
  • 写回答

1条回答 默认 最新

  • duanmengmiezen8855 2013-10-29 06:08
    关注

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

    $story = "My story begins with " . $_POST['story'];
    
    $newtext = wordwrap($story, 35, "
    ", true);
    $newertext = explode("
    ", $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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料