1 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",22 "number" => "0123456789",23 );24 if (empty($chars_range)) {25 $chars_rang = 'alpha-number';26 }27 if(strpos($chars_range, '-')) {28 $char_range_arr = explode('-',$chars_range);29 foreach($char_range_arr as $range){30 if(!array_key_exists($range, $char_arr)){31 exit("wrong range \"". $range ."\"");32 }33 $chars .= $char_arr[$range];34 }35 }else{36 if(!array_key_exists($chars_range, $char_arr)){37 exit("wrong range \"".$chars_range ."\"");38 }39 $chars = $char_arr[$chars_range];40 }41 while( strlen($str) < $length) {42 $str .= substr($chars, rand(0, strlen($chars) - 1), 1);43 }44 return $str;45 }46 47 ?>