PHP - random string

<?php function GetRandomString($lenght){ $availableChars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; $string = ""; $i = 0; while ($i < $lenght) { // estrazione casuale di un un carattere dalla lista possibili caratteri $char = substr($availableChars, rand(0, strlen($availableChars)-1),1); $string .= $char; $i = 1 + $i; } return $string; } ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.