You are here

function _monitoring_setup_random_name in Monitoring 7

Generates random name.

Parameters

int $length: Length of the generated string.

Return value

string The generated string.

2 calls to _monitoring_setup_random_name()
monitoring_demo_enable in test/monitoring_demo.install
Implements hook_enable().
_monitoring_setup_create_node in ./monitoring.setup.inc
Creates nodes for testing purposes.

File

./monitoring.setup.inc, line 209
Set up dependencies for demo and tests.

Code

function _monitoring_setup_random_name($length = 8) {
  $values = array_merge(range(65, 90), range(97, 122), range(48, 57));
  $max = count($values) - 1;
  $str = chr(mt_rand(97, 122));
  for ($i = 1; $i < $length; $i++) {
    $str .= chr($values[mt_rand(0, $max)]);
  }
  return $str;
}