1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| $valeur = array('1','2','3','4','5','6','7','8','9','A','B','C','D','E');
shuffle($valeur);
for($i=0;$i<5;$i++)
{
$val.=$valeur[$i];
}
$font_size = 8;
$width=imagefontwidth($font_size)*5;
$height=imagefontheight($font_size)*2;
$img = imagecreate($width,$height);
$bg = imagecolorallocate($img,255,255,255);
$black = imagecolorallocate($img,0,0,0);
$len=strlen($val);
for($i=0;$i<$len;$i++)
{
$xpos=$i*imagefontwidth($font_size);
$ypos=rand(0,imagefontheight($font_size));
imagechar($img,$font_size,$xpos,$ypos,$val,$black);
$val = substr($val,1);
}
header("Content-Type: image/gif");
imagegif($img);
imagedestroy($img); |
Partager