loadHTML($html);
$xpath = new DOMXPath($doc);
// Находим строки таблицы с курсами валют
$rows = $xpath->query('//table[contains(@class, "data")]//tr');
$currencies = [];
foreach ($rows as $row) {
$cols = $row->getElementsByTagName('td');
if ($cols->length > 0) {
$code = trim($cols->item(1)->nodeValue);
$rate = trim($cols->item(4)->nodeValue);
$currencies[$code] = $rate;
}
}
return $currencies;
}
// Используем функции
$date = "01.02.2024"; // Указанная дата
$html = getCurrencyPage($date);
$currencies = parseCurrencies($html);
// Выводим результат
echo "Курсы валют на дату $date:\n";
foreach ($currencies as $code => $rate) {
echo "$code: $rate\n";
}
?>