str_replace 只替换一次
<?php function str_replace_once($needle,$haystack) { $pos = strpos($haystack, $needle); if ($pos === false) { return $haystack; } return substr_replace($haystack, $replace, $pos, strlen($needle)); } echo str_replace_once($needle,$replace,$haystack);?>