-1

I have a string below

<?php
$str = '<td>1.06</td><td>9.30</td><td>16.08</td><td style="color:#009">0.70</td><td style="color:#009">3/3.5</td><td style="color:#009">1.00</td><td><font color="blue">L</font></td>';
?>

What function help us to get value of each < TD > tag and putting them into an array . Thank friends.

bambostar
  • 45
  • 8
  • parsing DOM tree is probably your best option. https://www.tutorialspoint.com/php/php_dom_parser_example.htm – Dimi Jul 24 '17 at 13:14
  • i actually only need to proccess that string . the DOM too much complex for this task . anyway thanks for your help ;) – bambostar Jul 24 '17 at 13:38

1 Answers1

0

Use php DomDocument

$dom = new DOMDocument();
$dom->loadHTMLFile("test.html");
$tables = $dom->getElementsByTagName('table');   

foreach ($table->childNodes as $td) {
  if ($td->nodeName == 'td') {
    echo $td->nodeValue, "\n";
  }
}
NID
  • 3,238
  • 1
  • 17
  • 28