Return to Snippet

Revision: 65617
at January 1, 2014 06:12 by wyattstorch42


Initial Code
<?php
/**
 * Generates a random string of a given length and character set.
 * @param int $l The length of the resulting string
 * @param string $c The character set
 * @return string The random sequence
 */
function mt_rand_str ($l, $c = 'abcdefghijklmnopqrstuvwxyz1234567890') {
	for ($s = '', $cl = mb_strlen($c)-1, $i = 0; $i < $l; $s .= mb_substr($c, mt_rand(0, $cl), 1), ++$i);
	return $s;
}
?>

Initial URL


Initial Description
Generates a random string of a given length and character set.

Initial Title
PHP Random String Function

Initial Tags
php

Initial Language
PHP