function shortcode_shortcode_random in Shortcode 7
Same name and namespace in other branches
- 6 shortcode.module \shortcode_shortcode_random()
Generates a random code
Calling [random length=X /]
Where X is the length of the random text. If the length empty or invalid, between 1-99, the length will be 8
File
- ./
shortcode.module, line 598
Code
function shortcode_shortcode_random($attrs, $text) {
extract(shortcode_attrs(array(
'length' => 8,
), $attrs));
$length = intval($length);
if ($length < 0 || $length > 99) {
$length = 8;
}
$text = '';
for ($i = 0; $i < $length; ++$i) {
$text .= chr(rand(32, 126));
}
return $text;
}