MySQL_Narb Posted January 29, 2013 Share Posted January 29, 2013 <tr> <td>3</td> <td>868</td> <td>9,167,674</td> </tr> <tr> <td>4</td> <td>60</td> <td>285,497</td> </tr> I'm curious, is there an easy way using preg_match to get the contents of the 3rd <td></td> occurrence? Quote Link to comment https://forums.phpfreaks.com/topic/273805-get-contents-of-3rd/ Share on other sites More sharing options...
requinix Posted January 29, 2013 Share Posted January 29, 2013 Use something like DOMDocument to get to it. Which would be easier to show if I had more to look at than just a single . Quote Link to comment https://forums.phpfreaks.com/topic/273805-get-contents-of-3rd/#findComment-1409044 Share on other sites More sharing options...
Kingy Posted January 29, 2013 Share Posted January 29, 2013 As mentioned above DOMDocument and Xpath is the easiest way to go about it. <?php $dom = new DOMDocument(); $dom->loadHTML($content); // $content is the HTML code $xpath = new DOMXPath($dom); $value = $xpath->query("//path/to/tr/td[3]/text()")->item(0)->nodeValue; // change this path to suit ?> Quote Link to comment https://forums.phpfreaks.com/topic/273805-get-contents-of-3rd/#findComment-1409063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.