Home  >  Article  >  Backend Development  >  PHP获取HTML标签解决方法

PHP获取HTML标签解决方法

WBOY
WBOYOriginal
2016-06-13 11:49:001098browse

PHP获取HTML标签

<html><br /><body><br /><tr id="ASPxGridView1_DXDataRow0" class="dxgvDataRow_Soft_Orange"><br />	<td class="dxgv">53</td><br />		<td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=外海&startm=&endtm=" target="_blank">1</a></td><br />		<td class="dxgv">2</td><br />		<td class="dxgv">3</td><br />		<td class="dxgv">4</td><br />		<td class="dxgv">6</td><br />		<td class="dxgv">7</td><br />		<td class="dxgv">8</td><br />		<td class="dxgv">9</td><br />		<td class="dxgv" style="border-right-width:0px;">10</td><br />	</tr><br />	<tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"><br />		<td class="dxgv">11</td><br />		<td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=j江苏&startm=&endtm=" target="_blank">12</a></td><br />		<td class="dxgv">13</td><br />		<td class="dxgv">14</td><br />		<td class="dxgv">15</td><br />		<td class="dxgv">16</td><br />		<td class="dxgv">17</td><br />		<td class="dxgv">18</td><br />		<td class="dxgv">19</td><br />		<td class="dxgv" style="border-right-width:0px;">20</td><br />	</tr><br />	<tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"><br />		<td class="dxgv">21</td><br />		<td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=上海&startm=&endtm=" target="_blank">22</a></td><br />		<td class="dxgv">23</td><br />		<td class="dxgv">24</td><br />		<td class="dxgv">25</td><br />		<td class="dxgv">26</td><br />		<td class="dxgv">27</td><br />		<td class="dxgv">28</td><br />		<td class="dxgv">29</td><br />		<td class="dxgv" style="border-right-width:0px;">30</td><br />	</tr><br /></tr><br /></body><br /></html>	


请教如何获得

标签中的1~30这些值呢?最好用simple_html_dom来获取?知道的朋友说下哦!如果不是用这个类也可以!
------解决方案--------------------
 $s=<<<html><br /><body><br /><tr id="ASPxGridView1_DXDataRow0" class="dxgvDataRow_Soft_Orange"><br />	<td class="dxgv">53</td><br />		<td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=外海&startm=&endtm=" target="_blank">1</a></td><br />		<td class="dxgv">2</td><br />		<td class="dxgv">3</td><br />		<td class="dxgv">4</td><br />		<td class="dxgv">6</td><br />		<td class="dxgv">7</td><br />		<td class="dxgv">8</td><br />		<td class="dxgv">9</td><br />		<td class="dxgv" style="border-right-width:0px;">10</td><br />	</tr><br />	<tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"><br />		<td class="dxgv">11</td><br />		<td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=j江苏&startm=&endtm=" target="_blank">12</a></td><br />		<td class="dxgv">13</td><br />		<td class="dxgv">14</td><br />		<td class="dxgv">15</td><br />		<td class="dxgv">16</td><br />		<td class="dxgv">17</td><br />		<td class="dxgv">18</td><br />		<td class="dxgv">19</td><br />		<td class="dxgv" style="border-right-width:0px;">20</td><br />	</tr><br />	<tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"><br />		<td class="dxgv">21</td><br />		<td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=上海&startm=&endtm=" target="_blank">22</a></td><br />		<td class="dxgv">23</td><br />		<td class="dxgv">24</td><br />		<td class="dxgv">25</td><br />		<td class="dxgv">26</td><br />		<td class="dxgv">27</td><br />		<td class="dxgv">28</td><br />		<td class="dxgv">29</td><br />		<td class="dxgv" style="border-right-width:0px;">30</td><br />	</tr><br /></tr><br /></body><br /></html>	
txt;
preg_match_all("#>(\d+)()?#isU",$s,$m);
print_r($m[1]);

------解决方案--------------------
<?php <br /><br>	$html = <br><br><tr>
<br>	<td>53</td>
<br>		<td><a>1</a></td>
<br>		<td>2</td>
<br>		<td>3</td>
<br>		<td>4</td>
<br>		<td>6</td>
<br>		<td>7</td>
<br>		<td>8</td>
<br>		<td>9</td>
<br>		<td>10</td>
<br>	</tr><br>	<tr><div class="clear">
                 
              
              
        
            </div></tr>
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