2010-12-15 132 views
1

我需要得到两件事情出一个HTML文件:和</title><body></body>之间 越来越部分

  1. 文本之间<title>
  2. 文本没有任何人知道这个怎么做?这是我到目前为止有:

    $contents = file_get_contents($_GET['file']); 
    $title = preg_replace("/.*<title[^>]*>|<\/title>.*/si", "", $file); 
    $body = preg_replace("/.*<body[^>]*>|<\/body>.*/si", "", $file); 
    

    我需要回响在一个文本在文本框中的标题和正文。

+0

*(相关)* [解析HTML的最佳方法](http://stackoverflow.com/questions/3577641/best-methods-to-parse-html/3577662#3577662) – Gordon 2010-12-15 20:15:02

+0

阅读[解析Html The Cthulhu Way ](http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html) – AlexV 2010-12-15 20:33:25

回答