我有一个带有HTML标签的字符串,我想爆炸成如下所示的数组
我正在考虑爆炸的标签是: p, h1, h2, h3, h4, h5, <ul>, <ol>
例子:
$data ="<p> Paragraph 1 </p> <h2>h2 tag 1 </h2> <p> Paragraph 2.</p> <p>Paragraph 3 </p> <ol> <li>pizza</li> <li>burgers</li> <li>salad</li> </ol> <ul> <li> <ul> <li> One </li> <li>Twp </li> <li>Three</li> </ul> </li> </ul> <p> Paragraph
5 </p> <p>Paragraph 6:</p> <h4> h4 tag</h4> <h1> h4 tag</h1> <h4> h4 tag</h4>"
我需要以下输出:
$array_tags= [
0 => <p> Paragraph 1 </p>,
1 => <h2>h2 tag 1 </h2>,
2 => <p> Paragraph 2 </p>,
3 => <p> Paragraph 3 </p>,
4 => <ol> <li>pizza</li> <li>burgers</li> <li>salad</li> </ol>,
5 => <p> Paragraph 4 </p>,
6 => <ul> <li> <ul> <li> One </li> <li>Twp </li> <li>Three</li> </ul> </li> </ul>,
7 => <p> Paragraph 5 </p>,
8 => <p> Paragraph 6 </p>,
9 => <h4> h4 tag</h4>,
10 => <h1> h1 tag</h1>,
];
有人可以帮忙吗?提前致谢!