/ Published in: PHP
This snippet generates a random string of random length
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function str_rand ($minlength, $maxlength, $useupper=true, $usespecial=false, $usenumbers=true) { $key =""; $charset = "abcdefghijklmnopqrstuvwxyz"; if ($useupper) $charset .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if ($usenumbers) $charset .= "0123456789"; if ($usespecial) $charset .= "~@#$%^*()_+-={}|]["; // Note: using all special characters this reads: "~!@#$%^&*()_+`-={}|\\]?[\":;'><,./"; return $key; }