[英]preg match in php to get data between html
I have the following html code 我有以下html代码
<pre
class="glossaryProduct">
data goes here
</pre>
and i need to pull just the "data goes here" between the pre and /pre. 我只需要在pre和/ pre之间拉“数据到这里”。 Can someone explain how this is done using preg_match? 有人可以解释一下如何使用preg_match吗?
Thanks 谢谢
In your simple case the "preg_match" approach would look as below: 在您的简单情况下,“ 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.