From e2afe6336238fd8d33922038ae1f652a4f46de6c Mon Sep 17 00:00:00 2001 From: jumpin-banana Date: Fri, 23 Apr 2010 11:13:15 +0200 Subject: [PATCH] random string function --- single-functions/random-string-AZ09.php | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 single-functions/random-string-AZ09.php 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; +} + +?> -- 2.39.5