Home  >  Article  >  Backend Development  >  怎么得到<td></td>中的内容

怎么得到<td></td>中的内容

WBOY
WBOYOriginal
2016-06-13 11:52:281438browse

如何得到

中的内容?


 
 

 
 
 

 
 
 

 
 
 
商标名称

尚杉彩

注册号/申请号9326603
国际分类号14申请日期2011/4/12

如何得到中的内容,感谢,能否贴出源码!!!!!
------解决方案--------------------
本帖最后由 xuzuning 于 2014-03-26 10:53:31 编辑
$s =<<< HTML<br /><table id="TMsDt" class="TMs"><br /><tr><br /><td class="TBdt1"><a name="TopHere" id="TopHere">商标名称</a></td> <br /><td class="TBdt2 tdp"><p>尚杉彩</p></td> <br /><br /><td class="TBdt1">注册号/申请号</td> <br /><td class="TBdt3">9326603</td> <br /></tr> <br /><br /><tr> <br /><td class="TBdt1">国际分类号</td> <br /><td class="TBdt2">14</td> <br /><br /><td class="TBdt1">申请日期</td> <br /><td class="TBdt3">2011/4/12</td> <br /></tr> <br /></table><br />HTML;<br />preg_match_all('#<(td)[^>]*>(.+)</\1#i', $s, $r);<br />print_r($r[2]);
Array<br />(<br />    [0] => <a name="TopHere" id="TopHere">商标名称</a><br />    [1] => <p>尚杉彩</p><br />    [2] => 注册号/申请号<br />    [3] => 9326603<br />    [4] => 国际分类号<br />    [5] => 14<br />    [6] => 申请日期<br />    [7] => 2011/4/12<br />)<br /><br />

------解决方案--------------------
引用:
非常感谢,如果同时能把html标签去掉就更好了,如

数组循环下,对值用strip_tags()
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn