php - preg_match() find all values inside of table? -
hey guys, curl function returns string $widget contains regular html -> 2 divs first div holds table various values inside of <td>'s. 
i wonder what's easiest , best way me extract values inside of <td>'s have blank values without remaining html. 
any idea pattern preg_match should like?
thank you.
you're betting off using dom parser task:
$html = <<<html <div> <table>    <tr>       <td>foo</td>       <td>bar</td>    </tr>    <tr>       <td>hello</td>       <td>world</td>    </tr> </table> </div> <div>    irrelevant </div> html;  $dom = new domdocument; $dom->loadhtml($html); $xpath = new domxpath($dom);  $tds = $xpath->query('//div/table/tr/td'); foreach ($tds $cell) {     echo "{$cell->textcontent}\n"; }   would output:
foo bar hello world      
Comments
Post a Comment