【发布时间】:2021-09-09 07:49:52
【问题描述】:
这是一些 HTML 代码
<!--start--> <h2>some content with any html tag</h2> <!--end-->
<!--start--> </h3> some other content with any html tag </h3><!--end-->
我需要一个 PHP 代码来读取 cmets 数据。棘手的部分是 cmets 是相同的,我需要两个内容。像 H2 和 H3。
我有代码,但它只提供一个。 H3.
$html_file = file_get_contents($allfiles[0]);
$string = '<!--start-->'.$html_file.'<!--end-->';
preg_match('/<!--start-->(.*)<!--end-->/', $string, $matches);
【问题讨论】:
-
试试
preg_match_all() -
它也不起作用。可以请你写一个代码。将不胜感激