本帖最后由 l2x11 于 2010-03-02 20:52:34 编辑

解决方案 »

  1.   

    echo str_replace('/test/','this','this is a test');
      

  2.   

    假设 echo "this is a test" >test.txt$filename = "test.txt"
    $fp = fopen($filename,"r"); //只读打开txt
    $str = fread($fp,filesize($filename));//读取内容
    $replace = "this";
    $str = str_replace("test",$replace,$str);
    fclose($fp);重新写入文件
    $handle = fopen($filename,"w"); //写入方式打开
    fwrite($handle,$str); //写入str
    fclose($handle);然后cat test.txt
      

  3.   

    $s = 'this is a test';
    preg_match_all('/[^ ]+/', $s, $r);
    $ret = join(' ', array_reverse($r[0]));echo $ret; // test a is this
      

  4.   

    explode 还是方面些..
    不准用这个.脑袋被门夹了..