From: jumpin-banana Date: Fri, 23 Apr 2010 09:13:15 +0000 (+0200) Subject: random string function X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=e2afe6336238fd8d33922038ae1f652a4f46de6c;p=dolphin.git random string function --- diff --git a/single-functions/random-string-AZ09.php b/single-functions/random-string-AZ09.php new file mode 100644 index 0000000..0cd5705 --- /dev/null +++ b/single-functions/random-string-AZ09.php @@ -0,0 +1,35 @@ +. + */ + +/** + * create a random A-Z 0-9 string with the given length + * @param string $lentgh Default 5 + * @return string The random string + */ +function randomAZ09($length=5) { + $str = ''; + for ($i=0; $i<$length; $i++) { + $d = rand(1,30)%2; + $str .= $d ? chr(rand(65,90)) : chr(rand(48,57)); + } + + return $str; +} + +?>