You are here

function devel_generate_word in Devel 6

Same name and namespace in other branches
  1. 5 devel_generate.inc \devel_generate_word()
  2. 7 devel_generate/devel_generate.inc \devel_generate_word()
3 calls to devel_generate_word()
devel_create_users in ./devel_generate.inc
Generate some random users.
devel_generate_terms in ./devel_generate.inc
devel_generate_vocabs in ./devel_generate.inc

File

./devel_generate.inc, line 208

Code

function devel_generate_word($length) {
  srand((double) microtime() * 1000000);
  $vowels = array(
    "a",
    "e",
    "i",
    "o",
    "u",
  );
  $cons = array(
    "b",
    "c",
    "d",
    "g",
    "h",
    "j",
    "k",
    "l",
    "m",
    "n",
    "p",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "tr",
    "cr",
    "br",
    "fr",
    "th",
    "dr",
    "ch",
    "ph",
    "wr",
    "st",
    "sp",
    "sw",
    "pr",
    "sl",
    "cl",
    "sh",
  );
  $num_vowels = count($vowels);
  $num_cons = count($cons);
  $word = '';
  while (strlen($word) < $length) {
    $word .= $cons[mt_rand(0, $num_cons - 1)] . $vowels[mt_rand(0, $num_vowels - 1)];
  }
  return substr($word, 0, $length);
}