-
- /**
- * @param string $type
- * @param $length
- * @return string
- */
- functionrandomString($type="数値,上,下位",$length){
- $valid_type = array('数値','上','下位') ;
- $case =explode(",",$type);
- $count = count($case);
- //による交集判断パラメータの適否
- if($count !== count(array_intersect($case,$ valid_type))){
- return false;
- }
- $ lower = "abcdefghijklmnopqrstuvwxyz";
- $upper = strtoupper($ lower);
- $number = "0123456789";
- $str_list = "";
- for($i= 0;$i<$count;++$i){
- $str_list .= $$case[$i];
- }
- return substr(str_shuffle($str_list),0,$length);
- }
- echo randomString ("数字,上,下",12);
复制代
|