Skip to content

Instantly share code, notes, and snippets.

@fhferreira
Last active December 27, 2015 11:19
Show Gist options
  • Save fhferreira/7318217 to your computer and use it in GitHub Desktop.
Save fhferreira/7318217 to your computer and use it in GitHub Desktop.
Generate Password
<?php
function GeneratePassword($length,$caracteres){
$password = "";
$length_c = strlen($caracteres);
while(strlen($password) < $length){
$pos = rand( 0 , $length_c - 1 );
$password .= $caracteres[$pos];
}
return $password;
}
echo GeneratePassword(7,'abczxc012394');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment