i am trying to take 9 values and make them unique double digit numbers
<?php
$numbers=range(10,99);
//Get 4 unique random keys from $numbers array.
$rand_keys = array_rand($numbers, 9);
//if you want to sort the random keys
sort($rand_keys);
//print out the random numbers using the
//random keys.
foreach ($rand_keys as $k=>$v) {
echo $numbers[$v].", ";
$test = $test . " " . $numbers[$v];
}
$test = substr($test, 1);
$ar = explode(" ", $test);
$myn = array($ar[0], $ar[1], $ar[2], $ar[3], $ar[4], $ar[5], $ar[6], $ar[7], $ar[8]);
?>
which is done
but then i try making it work like this ex:
$myn = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
to be used in here
<?php
/* image_grid.php
Click Captcha Ver 1.2
Created on: 10/27/2007 by Ron Hickey
Idea by http://www.6tx.net/forum member pappy
http://6tx.net/sc2 */
//buffer
ob_start('ob_gzhandler');
session_start();
//DEC 67
//get a, decode and round
//
$a = $_GET['a'];
if ($a == $_SESSION['afloat']){
$aa = round(base64_decode($a)) - 1;
$im = imagecreatetruecolor (135, 180);
//DEC 79
//random numbers
//
$myn = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
$rn = array_rand($myn, 9);
$string1 = "" . $myn[$rn[0]] . " " . $myn[$rn[1]] . " " . $myn[$rn[2]] . "";
$string2 = "" . $myn[$rn[3]] . " " . $myn[$rn[4]] . " " . $myn[$rn[5]] . "";
$string3 = "" . $myn[$rn[6]] . " " . $myn[$rn[7]] . " " . $myn[$rn[8]] . "";
$mynum = "" . $string1 . " " . $string2 . " " . $string3 . "";
$num0 = $myn[$rn[0]];
$num1 = $myn[$rn[1]];
$num2 = $myn[$rn[2]];
$num3 = $myn[$rn[3]];
$num4 = $myn[$rn[4]];
$num5 = $myn[$rn[5]];
$num6 = $myn[$rn[6]];
$num7 = $myn[$rn[7]];
$num8 = $myn[$rn[8]];
//DEC 68 DEC 69 DEC 66 DEC 89 DEC 82
//string, random click number and line coord
$na = 44;
$nb = 135;
$nc = 0;
$nd = 135;
$ab = explode(" ", $mynum);
$test = array("$ab[$aa] is IT", "$ab[$aa] Click IT!", "Click $ab[$aa]", "Select #$ab[$aa]", "Choose $ab[$aa]", "Push
$ab[$aa]", "Pounce $ab[$aa]", "Smack #$ab[$aa]", "Shmack $ab[$aa]", "Tag $ab[$aa]");
$rnd1 = array_rand($test, 10);
$mystring = $test[$rnd1[0]];
//random image color
//
$change = rand(1,8);
$blue = imagecolorallocate ($im, 176, 196, 222);
$white = imagecolorallocate($im,255,255,255);
$lgray = imagecolorallocate($im,206,206,206);
$gray = imagecolorallocate($im,115,115,115);
$black = imagecolorallocate($im,0,0,0);
$green = imagecolorallocate($im,1,107,0);
$grc = " $blue $white $lgray $blue $white $gray $black $green";
$rc = explode(" ", $grc);
$bgc = $rc[$change];
//DEC 72
//line & number colors
//
$bc = imagecolorallocate ($im, 0, 0, 0);
$wh = imagecolorallocate ($im, 255, 255, 255);
$pk = imagecolorallocate ($im, 219, 112, 147);
$br = imagecolorallocate ($im, 128, 128, 0);
//DEC 73
//if color = this change line & number color
//
if (($change > 3) && ($change < 8)) { $bc = $pk;}
elseif ($change == 2) { $bc = $br;}
elseif ($change == 1 or $change == 4 or $change == 8) { $bc = $wh;}
//DEC 67
//fill image color
//
imagefilledrectangle ($im, 1, 1, 135, 180, $bgc);
imagerectangle ($im, 0, 0, 134, 179, $bc);
//DEC 75
//vertical lines
//
for($i=$na;$i<=$nb;$i+=45)
imageline($im,$i,44,$i,180,$bc);
// Horizontal Lines
for($i=$na;$i<=$nb;$i+=44)
imageline($im,0,$i,135,$i,$bc);
//DEC 69
//image string
//
$font = '3.ttf';
//with font at 20, 66 is the top and 85 is bottom with font 2 and 3
//start row 1
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 10, 73, $bc, $font, $num0);
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 53, 73, $bc, $font, $num1);
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 98, 73, $bc, $font, $num2);
//end row 1
//start row 2
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 10, 117, $bc, $font, $num3);
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 53, 117, $bc, $font, $num4);
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 98, 117, $bc, $font, $num5);
//end row 2
//start row 3
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 10, 162, $bc, $font, $num6);
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 53, 162, $bc, $font, $num7);
$ang = "";
$ang = rand(-35, 35);
imagettftext($im, 15, $ang, 98, 162, $bc, $font, $num8);
//end row 3
//Add top text 15 top and 43 bottom
$heigh = rand(15, 43);
imagettftext($im, 15, 0, 7, $heigh, $bc, $font, $mystring);
for($i=$nc;$i<=$nd;$i+=3)
imagedashedline($im,$i,180,$i,rand(2,4),$bc);
//DEC 89
//header content
//
header("Content-Type: image/gif");
//DEC 48
//send image
//
imagegif($im);
//DEC 55
//destroy image
//
imagedestroy($im);
}
//flush
ob_end_flush();
?>
(the above code works with numbers as 1-9)
and it doesnt work anyone able to see what im doing wrong?
thanks