How to get content from specific tags when using file_get_contents
问题 For example i have one .txt file, called cache.txt. It contains some information, and i need to get content from <span class="date">**THESE**</span> tags. Any ideas? Thanks. 回答1: You can use Simple HTML DOM Example: cache.txt <span class="abc">Lorem Ipsum</span> <span class="date">THESE</span> <span class="def">Dolor sit amet</span> file.php <?php include 'simple_html_dom.php'; $html = file_get_html('cache.txt'); echo $html->find('span[class=date]',0); //Output: THESE ?> 回答2: **Check this out