array('R' => array(0, 0), 'G' => array(0, 0), 'B' => array(0,0) ), 'BG_COLOR' => array('R' => array(150, 230), 'G' => array(150, 230), 'B' => array(150, 230) ) ); $pos_x = 5; $pos_y = 20; $random = rand(0, (count($theme) - 1) );/* Get a random theme */ /** * Place each character into the image **/ $angle = 0; $size = 10; for($i = 0, $count = strlen($code); $i < $count; $i++) { $color = imagecolorallocate($im, rand($theme[$random]['CHAR_COLOR']['R'][0], $theme[$random]['CHAR_COLOR']['R'][1]), rand($theme[$random]['CHAR_COLOR']['G'][0], $theme[$random]['CHAR_COLOR']['G'][1]), rand($theme[$random]['CHAR_COLOR']['B'][0], $theme[$random]['CHAR_COLOR']['B'][1]) ); imagettftext($im, $size, $angle, $pos_x, $pos_y, $color, $font, $code{$i}); $pos_x += $width + 1; } /* Finally show image */ imagepng($im); imagedestroy($im); ?>