将所有标记和标记内容解析为数组?

时间:2015-03-02 14:07:22

标签: php parsing hyperlink

我希望能够在字符串中找到所有锚标记并将它们解析为如下数组:

$string = 'Lorem ipsum <a href="link1.php" title="title1">One</a> dolor sit amet, consectetur adipiscing elit. <a href="http://something.com/link2.php" title="title2">Two</a> Nunc augue nunc, ullamcorper at mattis';

输出到这样的数组:     阵列(         0 =&gt;             阵列(                 &#39;标题&#39; =&GT; &#39; TITLE1&#39 ;,                 &#39; HREF&#39; =&GT; &#39; link1.php&#39 ;,                 &#39;内&#39; =&GT; &#39;一个&#39 ;,             )         1 =&gt;             阵列(                 &#39;标题&#39; =&GT; &#39; TITLE2&#39 ;,                 &#39; HREF&#39; =&GT; &#39; http://something.com/link2.php&#39 ;,                 &#39;内&#39; =&GT; &#39;两个&#39 ;,             )     )

0 个答案:

没有答案