Genrate Random Number In Php

[Solved] Genrate Random Number In Php | Php - Code Explorer | yomemimo.com
Question : random number generator in php

Answered by : ankur-prajapati

you can use rand() function for that in php.
Example:
Generate random numbers between 1 to 50
<?php echo rand(1,50);
?>

Source : | Last Update : Sat, 18 Jul 20

Question : generate random number of 4 digit in php

Answered by : ankur-prajapati

<?php
$FourDigitRandomNumber = mt_rand(1111,9999);
echo $FourDigitRandomNumber;
?>

Source : https://www.howtocodeschool.com/2020/08/generate-4-digit-random-number-in-php.html | Last Update : Sat, 23 Oct 21

Question : php random number

Answered by : -n746j61qvtgj

rand(0,10);
or
random_int(0,10)

Source : | Last Update : Sat, 10 Oct 20

Question : php random number

Answered by : mattia-consiglio

// $min and $max are optional
rand($min,$max);

Source : https://www.php.net/manual/en/function.rand.php | Last Update : Tue, 21 Apr 20

Question : php random number generator

Answered by : atsu-emmanuel-terungwa

<?php echo rand(1,50);
?>

Source : | Last Update : Sun, 02 Aug 20

Question : php random number

Answered by : jarno-looij

<?php
// src/Controller/LuckyController.php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
class LuckyController
{ public function number(): Response { $number = random_int(0, 100); return new Response( '<html><body>Lucky number: '.$number.'</body></html>' ); }
}

Source : https://symfony.com/doc/current/page_creation.html | Last Update : Wed, 06 Apr 22

Question : Genrate Random number in php

Answered by : nilesh

function genrateRandomInteger($len = 10)	{	$last =-1; $code = '';	for ($i=0;$i<$len;$i++)	{	do {	$next_digit=mt_rand(0,9);	}	while ($next_digit == $last);	$last=$next_digit;	$code.=$next_digit;	}	return $code;	}

Source : | Last Update : Mon, 03 Jan 22

Question : Random Number PHP

Answered by : eric-tam

<?php
echo random(1, 100); //returns a random number between 1 to 100.
?>

Source : | Last Update : Sun, 10 Jul 22

Answers related to genrate random number in php

Code Explorer Popular Question For Php