<?php
/**
* Created by PhpStorm.
* User: wangzhen
* Date: 2018/4/27
* Time: 16:21
*/
//随机生成包括0-9,a-z,A-Z的五位数
$arr1=range(0,9);
$arr2=range("a","z");
$arr3=range("A","Z");
$arr4=array_merge($arr1,$arr2,$arr3);
//方法一
$res=array_rand($arr4,5);
foreach ($res as $val){
print_r($arr4[$val]);
}
echo "<br>";
//方法二
shuffle($arr4);
$res2=array_splice($arr4,0,5);
$str1=implode($res2);
print_r($str1);
echo "<br>";
//方法三
shuffle($arr4);
$res3=array_slice($arr4,0,5);
$str3=implode($res3);
print_r($str3);
?>