剥离html标题标记及其内容-在php中

剥离html标题标记及其内容-在php中,php,html,tags,strip-tags,Php,Html,Tags,Strip Tags,有没有办法去掉所有的H1H2,h3。。。标签及其内容? 我需要为一个任务获得一个干净的文本 另一个任务是只获取第一个h2内容,而不使用html标记 这是我的原件: <h2>Title of product</h2> </h3>Subtitle of product</h3> Here starts the first paragraph and goes on to the next... <h3>Subtitle of the p

有没有办法去掉所有的H1H2,h3。。。标签及其内容? 我需要为一个任务获得一个干净的文本

另一个任务是只获取第一个h2内容,而不使用html标记

这是我的原件:

<h2>Title of product</h2> </h3>Subtitle of product</h3> 
Here starts the first paragraph and goes on to the next... 
<h3>Subtitle of the paragraph</h3> Here goes on the second paragraph.
任务2:仅获取第一个h2标记的内容,仅此而已,如下所示:

Here starts the first paragraph and goes on to the next... 
Here goes on the second paragraph.
Title of product
希望你能帮助我。我不知道如何在php中实现这一点。 我知道你可以脱衣,但我不知道如何切断(任务2)一个特定的序列

我对任务1的尝试如下:

$copy = trim(preg_replace('/\t+/', '', htmlspecialchars($article->getCopy())))
它无法删除html标记中的内容。

您以前搜索过吗?使用这种方法