21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
$html = <<<STR
<div style="background-color:gray;" id="footer">
<a id="gotop" href="#" onclick="MGJS.goTop();return false;">Top</a>
<a id="powered" href="http://wordpress.org/">WordPress</a>
<div id="copyright">
Copyright © 2009 简单生活 —— Kevin Yang的博客
</div>
<div id="themeinfo">
Theme by <a href="http://www.neoease.com/">mg12</a>. Valid <a href="http://validator.w3.org/check?uri=referer">XHTML 1.1</a>
and <a href="http://jigsaw.w3.org/css-validator/">CSS 3</a>.
</div>
</div>
STR;
$reg = "/<(\/?)(\w+)(([^>]*?)id=['\"](\w+)['\"])*([^>]*?)>/im";
preg_match($reg, $html, $matches);
var_dump($matches);