Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate two numbers that are NOT equal in PHP

I need to generate two numbers that are NOT equal in PHP.

I know that I use $random1 = (rand()%9); to generate random a number between 0-9. I need to add something to this I guess.

Thanks!

like image 814
Fred Bergman Avatar asked Oct 11 '09 10:10

Fred Bergman


2 Answers

$random1 = 4;
$random2 = 5;
like image 133
overstood Avatar answered Oct 02 '22 07:10

overstood


$numbers = array_rand(range(0, 9), 2);

echo '<pre>';
print_r($numbers);
echo '</pre>';
like image 42
Alix Axel Avatar answered Oct 02 '22 08:10

Alix Axel