if($_GET["op"]=="replace"){
$str=$_GET["input"];
$pos=$_GET["input2"];
$apos=explode(',',$pos);
echo"After replaced:".str_replace($apos[0],$apos[1],$str);
}
当我给出一个输入句子hi this is a good day
并发出替换的指令,如is
。将另一个字替换为not
则输出为:hi thnot not good day
.
如何使输出为hi this not good day
我猜你想要这样的东西:
preg_replace("/'b(is)'b/", "not", $input_lines);
检查代码
if($_GET["op"]=="replace"){
$str=$_GET["input"];
$pos=$_GET["input2"];
$apos=explode(',',$pos);
echo"After replaced:".preg_replace("/'b(".$apos[0].")'b/", $apos[1], $str)
}