我有一个动态生成的字符串
<p style="line-height:22px;"><b>Abstract</b><br>
Aims: The purpose of this study was to investigate a possible role of serum LDH as a predictor of cancer.
</p>此字符串中的文本是动态的。我只想用explode函数从这个字符串中提取文本。到目前为止我的代码。但它只会给我一个空白的结果。没有错误,没有文本。我是php的新手。
这是我正在处理的页面的链接。
http://test.pjnmed.com/?mno=284644我想要摘要下面的文字。
$content = file_get_contents("https://www.ejmanager.com/index_myjournal.php?jid=" . $jid . "&mno=" . $_GET[mno]);
$abstract_text = explode('<p style="line-height:22px;"><b>Abstract</b><br>', $content);
$content = $abstract_text[1];
$abstract_text = explode('</p>', $content);
$content = $abstract_text[0];
echo $content;发布于 2018-03-27 09:29:32
Don't use regexes for parsing HTML
$previous_value = libxml_use_internal_errors(TRUE);
$string ='<p style="line-height:22px;"><b>Abstract</b><br>
Aims: The purpose of this study was to investigate a possible role of serum LDH as a predictor of cancer.
</p>';
$dom = new DOMDocument();
$dom->loadHTML($string);
$p = $dom->getElementsByTagName('p')->item(0);
$p->removeChild($p->getElementsByTagName('b')->item(0));
echo $p->textContent;
libxml_clear_errors();
libxml_use_internal_errors($previous_value);https://stackoverflow.com/questions/49503020
复制相似问题