function Make_password ($length = 8) { Password character set, you can add any character you need $chars = Array (' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' H ', ' I ', ' j ', ' K ', ' l ', ' m ', ' n ', ' o ', ' P ', ' Q ', ' R ', ' s ', ' t ', ' u ', ' V ', ' w ', ' x ', ' y ', ' z ', ' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', ' I ', ' J ', ' K ', ' L ', ' M ', ' N ', ' O ', ' P ', ' Q ', ' R ', ' S ', ' T ', ' U ', ' V ', ' W ', ' X ', ' Y ', ' Z ', ' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', '! ', ' @ ', ' # ', ' $ ', '% ', ' ^ ', ' & ', ' * ', ' (', ') ', '-', ' _ ', ' [', '] ', ' {', '} ', ' < ', ' > ', ' ~ ', ' ', ' + ', ' = ', ', ', ', ', ', ', ' '.', ';', ':', '/', '?', ''); Randomly taking $length array element key name in a $chars $keys = ($chars, $length); $password = '; for ($i = 0; $i < $length; $i + +) { To concatenate $length array elements into strings $password. = $chars [$keys [$i]]; } return $password; } |