You are here

function _footnotes_helper_randstr in Footnotes 5

Same name and namespace in other branches
  1. 5.2 footnotes.module \_footnotes_helper_randstr()
  2. 6.2 footnotes.module \_footnotes_helper_randstr()
  3. 6 footnotes.module \_footnotes_helper_randstr()
  4. 7.3 footnotes.module \_footnotes_helper_randstr()
  5. 7.2 footnotes.module \_footnotes_helper_randstr()

Helper function to return a random text string

Return value

random (lowercase) alphanumeric string

1 call to _footnotes_helper_randstr()
_footnotes_replace_callback in ./footnotes.module
Helper function called from preg_replace_callback() above

File

./footnotes.module, line 234
The Footnotes module is a filter that can be used to insert automatically numbered footnotes into Drupal texts.

Code

function _footnotes_helper_randstr() {
  $chars = "abcdefghijklmnopqrstuwxyz1234567890";
  $str = "";

  //seeding with srand() not neccessary in modern PHP versions
  for ($i = 0; $i < 7; $i++) {
    $n = rand(0, strlen($chars) - 1);
    $str .= substr($chars, $n, 1);
  }
  return $str;
}