RandString
string randString( int pass_len = 10, pass_chars=false );
The function returns a string of the specified length consisting of random characters. Random characters can be Latin letters and digits. For example, the function can be used to generate passwords.
Function parameters
Parameter | Description | Available from version |
---|---|---|
pass_len | Length of resulting random string. | |
Set of characters | Set of characters. Optional. By default: abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ0123456789.
can be an array of character classes and then the resulting string will contain at least one character from each class. Example:echo randString(7, array( "abcdefghijklnmopqrstuvwxyz", "ABCDEFGHIJKLNMOPQRSTUVWXYZ", "0123456789", "!@#\$%^&*()", )); |
Examples of use
<? $new_password = randString(7); echo "New password: ".$new_password; // print the string "New password: fK4ftTP" ?>
© «Bitrix24», 2001-2024