我有这个函数可以将一些随机字符放入字符串中:
function random($string) {
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$shuffle_start = substr(str_shuffle($chars), 0, 6);
$shuffle_end = substr(str_shuffle($chars), 0, 6);
$letters = str_split($string);
$str = '';
$count = count($letters);
foreach($letters AS $l) {
$count--;
$str .= $l;
if($count) {
$str .= substr(str_shuffle($chars), 0, 5);
}
}
return $shuffle_start . $str . $shuffle_end;
}
这个函数从字符串 "hello": 中打印出来aApi3VhKJrDjeAbCkalprX7ll7N0Qjo3qymiw
。现在,我想从字符串中删除随机字符,以便清楚地看到单词“hello”。
我怎样才能做到这一点?