summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2011-09-07 06:13:08 +0200
committerDerek Jones <derek.jones@ellislab.com>2011-09-07 06:13:08 +0200
commit32020e61bb311a071ed6dd8b583e83ebc8b98b08 (patch)
tree426ddb4d08eb9f2574c34198d018ab36d3b74501 /system/helpers
parent40d1a7684444f6a8eb4cda23d8822f0b258f0c3e (diff)
parent5feb8bb8c89875224049a44ae988500c532ed6d4 (diff)
Merge pull request #399 from druu/patch-1
Major speed improvement in function random_string()
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/string_helper.php9
1 files changed, 3 insertions, 6 deletions
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 9fa69f46c..dd8ffaddb 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -215,12 +215,9 @@ if ( ! function_exists('random_string'))
case 'nozero' : $pool = '123456789';
break;
}
-
- $str = '';
- for ($i=0; $i < $len; $i++)
- {
- $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
- }
+
+ $str = substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len);
+
return $str;
break;
case 'unique' :