You are here

function multiple_email_code in Multiple E-mail Addresses 6

Same name and namespace in other branches
  1. 5 multiple_email.module \multiple_email_code()
  2. 7 multiple_email.module \multiple_email_code()
  3. 2.x 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
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 584
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;
}