📅  最后修改于: 2022-03-11 15:00:35.454000             🧑  作者: Mango
function replace_keep_case($st1, $find1) {
/// set prefix and suffix here
$prefix="";
$suffix="";
$index=0;
$resultstring="";
while ($index < strlen($st1)) {
if (strtoupper(substr($st1, $index, strlen($find1)))==strtoupper($find1)) {
$resultstring.=$prefix.substr($st1, $index, strlen($find1)). $suffix;
$index=$index+strlen($find1);
} else {
$resultstring.=substr($st1, $index, 1);
$index++;
}
}
return $resultstring;
}