[英]preg match in php to get data between html
我有以下html代碼
<pre
class="glossaryProduct">
data goes here
</pre>
我只需要在pre和/ pre之間拉“數據到這里”。 有人可以解釋一下如何使用preg_match嗎?
謝謝
在您的簡單情況下,“ preg_match”方法如下所示:
$content = '<pre
class="glossaryProduct">
data goes here<br>
and here
</pre>';
preg_match("/<pre[^>]*?>(.*)<\/pre>/s", $content, $matches);
$result = $matches[1];
// now the $result contains the needed data
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.