现成的字符串替换函数str_replace.$str = "2001-04-04 12:12:34";
$str = str_replace("-",$str,"");
$str = str_replace(":",$str,"");不知道第一和第三个参数有没有搞反。

解决方案 »

  1.   

    好象反了:
    <?php
    $bodytag = str_replace("%body%", "black", "<body text=%body%>");
    echo $bodytag;
    ?> 
      

  2.   

    查看php帮助文件就知道了
    str_replace
    字串取代。
    语法: string str_replace(string needle, string str, string haystack);
    传回值: 字串
    本函式将字串 str 代入 haystack 字串中,将所有的 needle 置换成 str。[email protected] (11-Apr-1999) 指出在 PHP 3.0.7 版,本函式有些 bug,而 [email protected] (05-Jun-1999) 补充在 PHP 3.0.8 版本函式就回复正常了。
    下例将 %body% 以 black 取代
    <?php
    $bodytag = str_replace("%body%", "black", "<body text=%body%>");
    echo $bodytag;
    ?>