先将文件读到一个字串,然后
preg_replace('/^<[\\?].*[\\?]>/i','',$o_string);
楼主试试,突然忘记很多正则语法了

解决方案 »

  1.   

    不懂怎么提取这些html。你如果html里面也有类似php的代码呢?怎么提取?
      

  2.   

    你是说你只要
    <html><head>
    <meta http-equiv=Content-Type content=text/html; charset=gb2312>
    <meta name=GENERATOR content=Microsoft FrontPage 4.0>
    <meta name=ProgId content=FrontPage.Editor.Document>
    这些吗?
    这有什么意义呢?不都是你写进去的吗?
      

  3.   

    to xuzuning(唠叨):
    是我写进去的啊,,可是现在我想过滤掉,把他做成html页面..而不是php.
      

  4.   

    $s = file_get_contents("http://localhost/page.php");
    就可得到html代码了
      

  5.   

    /**
    * 去掉字符串的html标签
    *
    * @param string $str 包含html代码的字符串
    * @return $text 去掉html标签后的纯洁字符串
    */
    function html2txt($str)
    {
    $search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
                    '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly
                    '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags
                    '@<![\s\S]*?--[ \t\n\r]*>@'        // Strip multi-line comments including CDATA
    );
    $text = preg_replace($search, '', $str);
    return $text;
    }