you can use rand() function for that in php.
Example:
Generate random numbers between 1 to 50
<?php
echo rand(1,50);
?>
public static function generateRandomString($length = 6): string
{
$original_string = array_merge(range(0, 29), range('a', 'z'), range('A', 'Z'));
$original_string = implode("", $original_string);
return substr(str_shuffle($original_string), 0, $length);
}
mt_rand(1000, 9999)