Skip to content

Instantly share code, notes, and snippets.

@lucasferreira
Created November 6, 2017 12:14
Show Gist options
  • Select an option

  • Save lucasferreira/01ef7a1f5446464e8c8541dcab670afa to your computer and use it in GitHub Desktop.

Select an option

Save lucasferreira/01ef7a1f5446464e8c8541dcab670afa to your computer and use it in GitHub Desktop.
<?php
function randomPassword($len=8)
{
$chars = 'abcdefghijlmnopqrstuvxyzkw123456789';
$numChars = strlen($chars);
$pwd = '';
for ($i=0; $i<$len; $i++)
{
$pwd .= substr($chars, rand(1, $numChars) - 1, 1);
}
return $pwd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment