- substr: documentation ( source)
- str_shuffle: documentation ( source)
<?php
function random_password( $length = 8 ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
$password = substr( str_shuffle( $chars ), 0, $length );
return $password;
}
for ($i = 0 ; $i < 20 ; $i++) {
echo random_password()."\n";
}