anyone know what are the function in php for auto choose value... i mean, when i click the button, computer will auto to print/choose the value.... for example... i set the value that computer has to choose is A,B and C... so, when i click the button 'choose' for example, the computer will choose anyone of A, B, C..... (computer/machine will choose randomly)... please help me..... thanks....
here is small code example on how to use random: // setup an array of options $a = array('A', 'B', 'C'); // get a random number between 0 and the number of items in the above array (-1) $i = rand(0, count($a)-1); // print the value echo $a[$i];
There's a function called array_rand(), which is made for this purpose. No need to use count() and rest one.