You are here

public function FootnotesFilter::randstr in Footnotes 8.2

Helper function to return a random text string.

Return value

string Random (lowercase) alphanumeric string.

1 call to FootnotesFilter::randstr()
FootnotesFilter::replaceCallback in src/Plugin/Filter/FootnotesFilter.php
Helper function called from preg_replace_callback() above.

File

src/Plugin/Filter/FootnotesFilter.php, line 307

Class

FootnotesFilter
Provides a base filter for Footnotes filter.

Namespace

Drupal\footnotes\Plugin\Filter

Code

public function randstr() {
  $chars = "abcdefghijklmnopqrstuwxyz1234567890";
  $str = "";

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