//USAGE: $answer = numbercaptcha(); //****** Call this between
//****** $_POST will contain $_POST['number'] //****** Check if $_POST['number'] is == to $answer //OPERATORS: Add additional $opperators to the array for more varriation function numbercaptcha() { //Set first and second num rand(min,max) $firstnum = rand(5,8); $secondnum = rand(1,4); $coinflip = rand(1,2) % 2; //Picks a random equation type if($coinflip == 0) { $math = $firstnum + $secondnum; $operators = array("+","Added To","Plus"); $operatorschoice = rand(1,3) % 3; } else { $math = $firstnum - $secondnum; $operators = array("-","Minus"); $operatorschoice = rand(1,2) % 2; } echo $firstnum . " " . $operators[$operatorschoice] . " " . $secondnum . " = "; return $math; }