Skip to content

Instantly share code, notes, and snippets.

@MilkZoft
Created January 18, 2012 03:32
Show Gist options
  • Save MilkZoft/1630691 to your computer and use it in GitHub Desktop.
Save MilkZoft/1630691 to your computer and use it in GitHub Desktop.
codejobs - Random String - PHP
<?php
function randomString($length = 6) {
$consonant = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "x", "y", "z");
$vocal = array("a", "e", "i", "o", "u");
$string = NULL;
srand((double) microtime() * 1000000);
$max = $length / 2;
for($i = 1; $i <= $max; $i++) {
$string .= $consonant[rand(0, 19)];
$string .= $vocal[rand(0, 4)];
}
return $string;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment