you can use rand() function for that in php.
Example:
Generate random numbers between 1 to 50
<?php
echo rand(1,50);
?>
rand(0,10);
or
random_int(0,10)
<?
$numero = rand(0,100);
echo $numero;
?>
// $min and $max are optional
rand($min,$max);
<?php
echo rand(1,50);
?>
<?php
// src/Controller/LuckyController.php
namespace AppController;
use SymfonyComponentHttpFoundationResponse;
class LuckyController
{
public function number(): Response
{
$number = random_int(0, 100);
return new Response(
'<html><body>Lucky number: '.$number.'</body></html>'
);
}
}
rand();
<?php
echo random(1, 100); //returns a random number between 1 to 100.
?>