public static function htmlToCsv($html)
{
$html = str_replace(array("\t", "\r", "\n"), "", $html);
$csv = "";
$doc = new \DOMDocument();
@$doc->loadHTML($html);
$xpath = new \DOMXPath($doc);
$results = $xpath->query('//tr');
foreach ($results as $result) {
$doc = new \DOMDocument();
@$doc->loadHTML(\Oara\Utilities::DOMinnerHTML($result));
$xpath = new \DOMXPath($doc);
$resultsTd = $xpath->query('//td');
$countTd = $resultsTd->length;
$i = 0;
foreach ($resultsTd as $resultTd) {
$value = $resultTd->nodeValue;
if ($i != $countTd - 1) {
$csv .= \trim($value) . ";";
} else {
$csv .= \trim($value);
}
$i++;
}
$csv .= "\n";
}
$exportData = \str_getcsv($csv, "\n");
return $exportData;
}