我目前正在尝试隐藏字符并将其更改为下划线("_"
)。
到目前为止,我已经尝试了这两组代码,它们都输出了单词的部分字符串和部分"_"
function hide($answer)
{
$hideCount = floor((sizeof($answer)/2) + 1);
$count = 0;
$hidden = $answer;
while ($count < $hideCount )
{
$element = sizeof($answer)-2;
if( $hidden[$element] != '_' ){
$hidden = str_replace($hidden[$element],'_',$hidden,$replace_count);
$count = $count + $replace_count;
}
}
return $hidden;
}
<?php function hide($answer){
$_SESSION['wordLength'] = strlen($answer);
$hidden = $answer;
return $hidden;
}