note 109530 added to function.imagestring

From: Date: Thu, 26 Jul 2012 15:42:58 +0000
Subject: note 109530 added to function.imagestring
Groups: php.notes 
Request: Send a blank email to php-notes+get-189408@lists.php.net to get a copy of this message
this simple method wrap the text that is "larger" than the image width. the sample was found in http://www.digimantra.com/technology/php/wrap-text-when-creating-images-on-the-fly-in-php/ <?php $text='The quick brown fox was so long but it still jumped over the lazy dog.'; //aca se usa la funcion wordwrap para "darle enter" al texto si se desborda del //tamaño definido $arrText=explode("\n",wordwrap($text,20,"\n")); $im = @imagecreate(200, 100); //creates an image $background_color = imagecolorallocate($im, 0, 0, 0); //sets image background color $y=5; //vertical position of text foreach($arrText as $arr) { $white=imagecolorallocate($im,255,255,255); //sets text color imagestring($im,5,15,$y,trim($arr),$white); //create the text string for image,added trim() to remove unwanted chars $y=$y+15; } header("Content-type: image/png"); imagepng($im); imagedestroy($im); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 201.244.200.109 ---- Manual Page -- http://www.php.net/manual/en/function.imagestring.php Edit -- https://master.php.net/note/edit/109530 Del: integrated -- https://master.php.net/note/delete/109530/integrated Del: useless -- https://master.php.net/note/delete/109530/useless Del: bad code -- https://master.php.net/note/delete/109530/bad+code Del: spam -- https://master.php.net/note/delete/109530/spam Del: non-english -- https://master.php.net/note/delete/109530/non-english Del: in docs -- https://master.php.net/note/delete/109530/in+docs Del: other reasons-- https://master.php.net/note/delete/109530 Reject -- https://master.php.net/note/reject/109530 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189408) next »