rand(0, 1), 1 => rand(0, 1), 2 => rand(0, 2)); $parts = array(0 => '', 1 => '', 2 => ''); if ($choices[0]) $parts[0] = rand(1, rand(9,99)); if ($choices[1]) $parts[2] = rand(1, rand(9,99)); $len -= (strlen($parts[0]) + strlen($parts[2])); for ($i = 0; $i < $len; $i++) { if ($i % 2 == 0) $parts[1] .= chr(rand(97, 122)); else $parts[1] .= $vowels[array_rand($vowels)]; } if ($choices[2]) $parts[1] = ucfirst($parts[1]); if ($choices[2] == 2) $parts[1] = strrev($parts[1]); $r = $parts[0] . $parts[1] . $parts[2]; $r = str_replace($confusing, $replacements, $r); return $r; } /** * EXAMPLE: */ echo makePassword(12); ?>