PHP获取HTML标签解决方法

WBOY
Lepaskan: 2016-06-13 11:49:00
asal
1094 orang telah melayarinya

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>	
Salin selepas log masuk


请教如何获得标签中的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]);
Salin selepas log masuk

------解决方案--------------------

<?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>
Salin selepas log masuk
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!