You are here

function multiple_email_code in Multiple E-mail Addresses 5

Same name and namespace in other branches
  1. 6 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:

string $chars:

Return value

string

2 calls to multiple_email_code()
multiple_email_confirm_form_submit in ./multiple_email_confirm_page.inc
Process multiple_email_confirm_form submission
multiple_email_register_email in ./multiple_email.module
Adds an unconfirmed email address to the email registry.

File

./multiple_email.module, line 476
multiple_email module file

Code

function multiple_email_code($length, $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUBWXYZ0123456789') {
  $cl = strlen($chars) - 1;
  $out = '';
  for ($i = 0; $i < $length; $i++) {
    $out .= $chars[rand(0, $cl)];
  }
  return $out;
}