Example of PHP randomly generating a random number of letter combinations

  • 2020-12-13 18:51:59
  • OfStack

In many systems, you will use a variety of combinations of letters, and the PHP code is recommended.

$num consists of several letters.

The $s letter contains upper and lower case. You can adjust both upper and lower case.
 
function makecode($num=4) { 
$re =  " ; 
$s =  ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; 
while(strlen($re)<$num) { 
$re .= $s[rand(0, strlen($s)-1)]; // from $s Medium random generation 1 A character  
} 
return $re; 
} 

Related articles: