function multiple_email_code in Multiple E-mail Addresses 2.x
Same name and namespace in other branches
- 5 multiple_email.module \multiple_email_code()
- 6 multiple_email.module \multiple_email_code()
- 7 multiple_email.module \multiple_email_code()
Generates a random string of given length from given characters.
If no characters are specified, then it uses a-zA-Z0-9. Characters are specified as a string containing every valid character. Duplicates will (in theory) increase that character's chances of occurring in the random string.
Parameters
integer $length Length of the random code. Defaults to 10 characters.:
string $chars:
Return value
string
3 calls to multiple_email_code()
- multiple_email_confirm_form_validate in ./
multiple_email_confirm_page.inc - @todo Please document this function.
- multiple_email_confirm_page_resend_submit in ./
multiple_email_confirm_page.inc - Callback for resending a confirmation email.
- multiple_email_register_email in ./
multiple_email.module - Adds an unconfirmed e-mail address to the e-mail registry.
File
- ./
multiple_email.module, line 543 - multiple_email module file
Code
function multiple_email_code($length = 10, $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUBWXYZ0123456789') {
$cl = drupal_strlen($chars) - 1;
$out = '';
for ($i = 0; $i < $length; $i++) {
$out .= $chars[mt_rand(0, $cl)];
}
return $out;
}