--------------EDIT------------------------
So i am going with the DOM approach. Here is what I have so far:
I've updated your edit to fix it.
function tdrows($elements)
{
$str = "";
foreach ($elements as $element) {
$str .= $element->nodeValue . ", ";
}
return $str;
}
function getdata()
{
$contents = "Row 1 Column 1 Row 1 Column 2 Row 2 Column 1 Row 2 Column 2
";
$DOM = new DOMDocument;
$DOM->loadHTML($contents);
$items = $DOM->getElementsByTagName('tr');
foreach ($items as $node) {
echo tdrows($node->childNodes) . "
";
}
}
getdata();