I'm trying to make a generated random characters. I'm concatenating the values of $char_type using foreach loop but it doesn't show anything. Here's my code:
public function randomizer($range, $type) {
$strtester = '';
$char_type = array('alp_sm' => 'abcdefghijklmnopqrstuvwxyz',
'alp_cs' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'num' => '0123456789',
'sp' => '!@#$%^&*()');
if(is_array($type)) {
foreach($type as $row) {
if(in_array($row, $char_type)) {
$strtester .= $char_type[$row];
}
}
}
print_r($strtester); exit();
$seed = str_split($strtester);
shuffle($seed);
$generated_string = '';
foreach (array_rand($seed, $range) as $k) $generated_string .= $seed[$k];
return $generated_string;
}
Update:
What i want to get from $strtester
is for example I want $char_type
alp_sm and alp_cs then the $strtester
will get abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Thank you in advance