我有以下功能,使用str_replace
会产生意想不到的结果
function repo($text) {
$search = array("0","1","2","3","4","5","6","7","8","9");
$replace = array("z30","z31","z32","z33","z34","z35","z36","z37","z38","z99");
$text = str_replace($search,$replace,$text);
return $text;
}
echo repo('0');
预期的答案是
z30
相反,我得到
zz330
我究竟做错了什么?