Skip to content

Instantly share code, notes, and snippets.

@mahendrakalkura
Last active August 29, 2015 14:10
Show Gist options
  • Save mahendrakalkura/b00be0fabd7f027d9968 to your computer and use it in GitHub Desktop.
Save mahendrakalkura/b00be0fabd7f027d9968 to your computer and use it in GitHub Desktop.
<?php
function get_password()
{
$one = array(
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
);
$two = array(
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
);
$three = array(
'!',
'#',
'$',
'%',
'&',
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
':',
';',
'<',
'=',
'>',
'?',
'@',
'{',
'|',
'}',
'~',
);
$password = array();
foreach (array_rand($one, 4) as $key) {
$password[] = $one[$key];
}
foreach (array_rand($one, 4) as $key) {
$password[] = strtolower($one[$key]);
}
foreach (array_rand($two, 4) as $key) {
$password[] = $two[$key];
}
foreach (array_rand($three, 4) as $key) {
$password[] = $three[$key];
}
shuffle($password);
return implode('', $password);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment