My problem is that I am using the random string creator shown below, I am not using 'alpha', I am using 'fourlet'. The only problem is that this in an array and that
substr($pool, mt_rand(0, strlen($pool) -1), 1);
doesn't work as a random creator for an array of data. Can anyone please help?
Below is the full code for the helper.
{
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 'fourlet' : $pool = array('my', 'fun', 'zone', '12', '24', '37');
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;
}
}
}
So