PHP解析HTML字符串的方式

Tho*_*ggi 5 html php rss simplepie

我有一个PHP字符串,其中包含我从RSS源检索的以下HTML.我使用简单的馅饼,无法找到任何其他方式来分割这两个数据集<description>.如果有人知道在简单的馅饼中选择一个很棒的孩子.

<div style="example"><div style="example"><img title="example" alt="example" src="example.jpg"/></div><div style="example">EXAMPLE TEXT</div></div>

to:

$image = '<img title="example" alt="example" src="example.jpg">';
$description = 'EXAMPLE TEXT';
Run Code Online (Sandbox Code Playgroud)

Sad*_*dat 9

$received_str = 'Your received html';

$html = str_get_html($received_str);

//Image tag
$img_tag = $html->find("img", 0)->outertext;

//Example Text
$example_text = $html->find('div[style=example]', 0)->last_child()->innertext;
Run Code Online (Sandbox Code Playgroud)

见:http://simplehtmldom.sourceforge.net/manual.htm