日期:2014-05-16 浏览次数:20561 次
<table width="96%"border="0" align="center" cellpadding="4" cellspacing="0">
<tr onMouseOver="this.style.backgroundColor='#EAEAEA'; return true;" onMouseOut="this.style.backgroundColor='transparent';">
<td><a href="news_detail.php?infoId=141" class="link">新闻一</a></td>
<td align="right" class="newstime">2014-03-12</td>
</tr>
<tr onMouseOver="this.style.backgroundColor='#EAEAEA'; return true;" onMouseOut="this.style.backgroundColor='transparent';">
<td><a href="news_detail.php?infoId=140" class="link">新闻二</a></td>
<td align="right" class="newstime">2014-02-20</td>
</tr>
</table>
<ul data-role="listview" >
<li><a href="#">新闻一 2014-03-12</a></li>
<li><a href="#">新闻二 2014-02-20</a></li>
</ul>
$s=<<< TXT
<table width="96%"border="0" align="center" cellpadding="4" cellspacing="0">
<tr onMouseOver="this.style.backgroundColor='#EAEAEA'; return true;" onMouseOut="this.style.backgroundColor='transparent';">
<td><a href="news_detail.php?infoId=141" class="link">新闻一</a></td>
<td align="right" class="newstime">2014-03-12</td>
</tr>
<tr onMouseOver="this.style.backgroundColor='#EAEAEA'; return true;" onMouseOut="this.style.backgroundColor='transparent';">
<td><a href="news_detail.php?infoId=140" class="link">新闻二</a></td>
<td align="right" class="newstime">2014-02-20</td>
</tr>
</table>
TXT;
preg_match_all('#<tr[^>]+>\s*<td><a[^>]+>(.+?)</a></td>\s*<td[^>]+>(.+?)<#s',$s,$m);
$html="<ul data-role=\"listview\" >\n";
foreach($m[1] as $k=>$v) $html .= "<li><a href=\"#\">$v {$m[2][$k]}</a></li>\n";
$html .= '</ul>';
echo $html;