尝试以下操作:
function guru20_ReplaceWords($text){
$replace = array(\'WordPress Codex\' => \'<a href="http:/codex.wordpress.com">WordPress Codex [EN]</a>\',
\'WPRecipes\'=> \'<a href="http://www.wprecipes.com" target="_blank">WPRecipes [EN]</a>\',
\'f.php\' => \'In die Datei functions.php einfügen.\');
$text = str_replace_first(array_keys($replace), $replace, $text);
return $text;
}
add_filter(\'the_content\', \'guru20_ReplaceWords\');
add_filter(\'the_excerpt\', \'guru20_ReplaceWords\');
function str_replace_first($from, $to, $subject)
{
$from = \'/\'.preg_quote($from, \'/\').\'/\';
return preg_replace($from, $to, $subject, 1);
}
你可以试试
preg_replace