Skip to content

Instantly share code, notes, and snippets.

@kosinix
Last active August 29, 2015 14:06
Show Gist options
  • Save kosinix/86ad6790cc2ef42545c7 to your computer and use it in GitHub Desktop.
Save kosinix/86ad6790cc2ef42545c7 to your computer and use it in GitHub Desktop.
Generate Password 12 characters long with some characters removed (l,1,0,o) for readability
<?php
function generateRandomString($length = 12) {
$characters = '23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ !@#$%^&*()_-';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment