function random_string in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle_support.php \random_string()
1 call to random_string()
- make_unique_id_code in includes/
moodle_support.php
File
- includes/
moodle_support.php, line 179
Code
function random_string($length = 15) {
$pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$pool .= 'abcdefghijklmnopqrstuvwxyz';
$pool .= '0123456789';
$poollen = strlen($pool);
mt_srand((double) microtime() * 1000000);
$string = '';
for ($i = 0; $i < $length; $i++) {
$string .= substr($pool, mt_rand() % $poollen, 1);
}
return $string;
}