Below is very easy function to generate random string in php.
1 2 3 4 5 6 7 8 9 10 11 | function Password_genrator( $length = 10) { $characters = '0123456789!@#$%^&*abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $charactersLength = strlen ( $characters ); $randomString = '' ; for ( $i = 0; $i < $length ; $i ++) { $randomString .= $characters [rand(0, $charactersLength - 1)]; } return $randomString ; } echo Password_genrator(); |
No comments:
Post a Comment