Jump to content

[fixed]can't Make A Function With My Snippets


Matpatnik
 Share

Recommended Posts

The code below works good alone so fare but I need to call it more then once.Copy and paste can't be the solution, I hope hehe!a soon as I wrap this snippets to create a function out of it it give me this error:

the image ... cannot be displayed, because it contain errors.
I tried to wrap only the foreach() as a function, same errorWhere ever I wrap it it give me the error.can someone give me a hand on this plz, Thank you.
$fontSize = 15;$ox = 10;$y = 40;$text = $row['description'];// Set the content-typeheader('Content-type: image/png');// Create the image$im = imagecreatetruecolor(750, 300);// Create some colors$beige = imagecolorallocate($im, 255, 206, 122);$dark_red = imagecolorallocate($im, 193, 0, 0);$grey = imagecolorallocate($im, 128, 128, 128);$black = imagecolorallocate($im, 0, 0, 0);imagefill($im, 0, 0, $beige);$text = text_to_array($text);foreach ($text as &$value){	$x = $ox;	foreach ($value as &$val)	{		$mod = 0;				if (substr($val, 0, 3) == '[B]')		{			$val = substr($val, 3);			$mod = 1;		} else if (substr($val, 0, 3) == '[I]')		{			$val = substr($val, 3);			$mod = 2;		} else if (substr($val, 0, 4) == '[BI]')		{			$val = substr($val, 4);			$mod = 3;		}		// Bounding box		$bbox = imagettfbbox($fontSize, 0, 'Fonts/'. $fonts['bkant'][$mod], $val);				imagettftext($im, $fontSize, 0, $x, $y, $black, 'Fonts/'. $fonts['bkant'][$mod], $val);		$x += $bbox[2] + 10;	}	$y += $bbox[1] + ($bbox[1] - $bbox[5]) + 5;}unset($val);unset($value);// Using imagepng() results in clearer text compared with imagejpeg()imagepng($im);imagedestroy($im);

Edited by Matpatnik
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...