How do I pick a random value from an array?
$lottery = range(1,49);
$onenumber = array_rand($lottery);
echo "One number is: $onenumber\n\n";
This will print a random number between 1 and 49.
You can also use array_rand to return a certain number of random numbers.
People often like to write a little computer program to generate their weekly lottery numbers for them. Here's how to create a lottery number generator for the UK lottery that picks six random numbers between 1 and 49 in just one line of PHP code:
foreach(array_rand(range(1,49),6) as $number) echo "$number ";
This will print a random selection of six numbers to the screen, for instance:
27 33 48 21 19 43
More arrays PHP Questionsreverse an array
hi, i am querying the DB as follows: $result=mysql_query("SELECT name,items FROM mytable WHERE user_id='$id'"); now,i want to create an array to insert the values that are as a result of this query e'g let's say this is the resultant data: n
what is arrays
I want to invert my array, can I do this?
How do I find the size of an array?