2009-11-23 188 views
2
<table width="100%" cellspacing="0" cellpadding="0" border="0" id="Table4"> 
    <tbody> 
    <tr> 
     <td valign="top" class="tx-strong-dgrey"> 
     <a class="anc-noul" href="http://www.example.com/catalog/proddetail.asp?logon=&amp;langid=EN&amp;sku_id=0665000FS10129471&amp;catid=25653"> 
      Apple 8GB 3rd Generation iPod Touch</a></td> 
    </tr> 
    <tr> 
     <td valign="top" class="element-spacer"/> 
    </tr> 
    <tr> 
     <td valign="top" class="tx-normal-grey"> 
     Product detail 
     <a href="http://www.example.com/catalog/proddetail.asp?logon=&amp;langid=EN&amp;sku_id=0665000FS10129471&amp;catid=25653"> 
      More Info</a></td> 
    </tr> 
    <tr> 
     <td valign="top" class="element-spacer"/> 
    </tr> 
    <tr> 
     <td valign="top" class="tx-normal-red"> 
     <span class="tx-strong-dgrey">Price:</span> 
     $189.99</td> 
    </tr> 
    <tr> 
     <td valign="top">You save: $9.00 after instant savings</td> 
    </tr> 
    <tr> 
     <td valign="top" class="element-spacer"/> 
    </tr> 
    <tr> 
     <td valign="top" class="tx-normal-grey"> 
     <a href="http://www.example.com/catalog/subclass.asp?catid=25653&amp;logon=&amp;langid=EN"> 
      View similar products</a> 
     <a href="http://www.example.com/catalog/mfr.asp?man=Apple&amp;catid=19&amp;logon=&amp;langid=EN"> 
      View similar products with same brand</a> 
     </td></tr> 
    <tr> 
     <td valign="top" class="element-spacer"/> 
    </tr> 
    </tbody> 
</table> 

我希望能夠獲得189.99美元。PHP HTML DOM解析

echo $ret[0]->find('tr', 4)->plaintext; 

此輸出: '價格:$ 189.99'

我只需要$ 189.99,而不是 '價格:'

+0

什麼'vardump($漚[0] - >查找(」 tr',4))'給你? – powtac 2009-11-23 17:45:17

+0

致命錯誤:調用未定義的函數vardump()在C:\ xampp \ htdocs \ ... – manny 2009-11-23 17:47:24

+3

var_dump()是他的意思 – 2009-11-23 17:48:34

回答

3
$exp = explode(":", $ret[0]->find('tr', 4)->plaintext); 
$price =$exp[1]; 
+0

就是這樣。你們很棒。 – manny 2009-11-23 17:59:06