function shortcode_basic_tags_shortcode_random in Shortcode 7.2
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.
1 string reference to 'shortcode_basic_tags_shortcode_random'
- shortcode_basic_tags_shortcode_info in shortcode_basic_tags/
shortcode_basic_tags.module - Implements hook_shortcode_info().
File
- shortcode_basic_tags/
shortcode_basic_tags.module, line 960 - Provides basic ShortCodes (as examples).
Code
function shortcode_basic_tags_shortcode_random($attrs, $text) {
$attrs = shortcode_attrs(array(
'length' => 8,
), $attrs);
$length = intval($attrs['length']);
if ($length < 0 || $length > 99) {
$length = 8;
}
$text = '';
for ($i = 0; $i < $length; ++$i) {
$text .= chr(rand(32, 126));
}
return $text;
}