str_replace
(PHP3 >= 3.0.6 , PHP4)
str_replace --- 取代所有在字串中出現的字串
語法 :
string str_replace(string needle, string str, string haystack)說明 :
此函式將所有在參數 haystack中出現的 needle以參數 str取代。如果你不需要這個取代的規則,你可以使用ereg_replace( )來代替此函式。
Example :
<?php
$bodytag = str_replace ("%body%", "black", "<body text=%body%>");
?>
注意 : 此函式是PHP 3.0.6中新增的函式
參考 : ereg_replace( ) strtr( )