[eluser]mr daniel[/eluser]
Hi guys.
In my directory. localhost/system/helpers/string_helper.php
I have
Code:
if ( ! function_exists('random_string'))
{
function random_string($type = 'alnum', $len = 8)
{
switch($type)
{
case 'basic' : return mt_rand();
break;
case 'alnum' :
case 'numeric' :
case 'nozero' :
case 'alpha' :
switch ($type)
{
case 'alpha' : $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alnum' : $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'numeric' : $pool = '0123456789';
break;
case 'nozero' : $pool = '';
break;
}
$str = '';
for ($i=0; $i < $len; $i++)
{
$str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
}
return $str;
break;
case 'unique' :
case 'md5' :
return md5(uniqid(mt_rand()));
break;
case 'encrypt' :
case 'sha1' :
$CI =& get_instance();
$CI->load->helper('security');
return do_hash(uniqid(mt_rand(), TRUE), 'sha1');
break;
}
}
}
I want to replace the
Code:
case 'nozero' : $pool = '';
break;
with something that has three words and three numbers in it.
So like
Code:
case 'word' : $pool = '(my)(fun)(zone)(12)(24)(37)';
break;
Is there a way to group letters and numbers together? I need this for my website as the words must relate to the site in question!