我想向我的客户建议可能的话:
t.est 测试 测试 测试 测试 t.e.s.t
现在我的代码是?
<?php
$string = "test";
$array = str_split($string);
foreach($array as $letter){
echo $letter.".";
}
答案 0 :(得分:2)
我希望这能解决你的问题:
$string = "test";
$array = str_split($string);
$len = strlen($string);
$rand_indx = mt_rand(0,$len);
if ($rand_indx == $len) {
$array[$rand_indx] = ".";
} else {
for ($x=$len; $x > $rand_indx; $x--) {
$array[$x] = $array[$x-1];
}
$array[$rand_indx] = ".";
}
foreach($array as $letter){
echo $letter;
}