Merge pull request #399 from druu/patch-1
Major speed improvement in function random_string()
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 9fa69f4..dd8ffad 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -215,12 +215,9 @@
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' :
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index fb6e449..cdbbe6b 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -77,6 +77,7 @@
<li>Added <samp>increment_string()</samp> to <a href="helpers/string_helper.html">String Helper</a> to turn "foo" into "foo-1" or "foo-1" into "foo-2".</li>
<li>Altered form helper - made action on form_open_multipart helper function call optional. Fixes (#65)</li>
<li><samp>url_title()</samp> will now trim extra dashes from beginning and end.</li>
+ <li>Improved speed of <a href="helpers/string_helper.html">String Helper</a>'s <b>random_string()</b> method</li>
</ul>
</li>
<li>Database