note 109530 deleted from function.imagestring by danbrown

From: Date: Mon, 30 Jul 2012 15:53:13 +0000
Subject: note 109530 deleted from function.imagestring by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189494@lists.php.net to get a copy of this message
Note Submitter: sainthyoga at gmail dot com ---- 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); ?>

« previous php.notes (#189494) next »