<?php //取出随机的字符串 例如验证码 header("content-type:text/html;charset=utf8"); //range 建立一个包含指定范围单元的数组 //array_merge //合并数组 // array_merge //合并数组 //array_rand() 从数组中随机取出一个或多个单元,返回值为数组,是由原数组的下标构成的 $arr = array_merge(range(1,9),range('a','z')); $index = array_rand($arr,5); //shufle //将数组再一次打乱 shuffle($index); $code =''; foreach($index as $key =>$value){ $code .= $arr[$value]; }
echo $code;