function getsalt($l1=6){ // 去掉了 0 1 O l 等 $l2 = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVW"; for ($i=0; $i<$l1; $i++){ $l3.= $l2[mt_rand(0, strlen($l2)-1)];//$l2{1} } return $l3; } echo getsalt(); $l2='abcde'; echo $l2[2];