折扣

loadHTML($html);
$table = $dom->getElementsByTagName(‘table’)->item(0); // 根据实际表格索引调整

// 提取数据
$results = [];
$rows = $table->getElementsByTagName(‘tr’);
foreach ($rows as $row) {
$cells = $row->getElementsByTagName(‘td’);
if ($cells->length >= 3) { // 根据列数调整
$title = trim($cells->item(0)->textContent);
$discount_price = trim($cells->item(1)->textContent);
$original_price = trim($cells->item(2)->textContent);
$results[] = [
‘title’ => $title,
‘discount_price’ => $discount_price,
‘original_price’ => $original_price
];
}
}

// 输出 HTML 表格
if (!empty($results)) {
echo ‘

‘;
echo ‘

‘;
foreach ($results as $game) {
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
}
echo ‘

游戏名称 折扣价 原价
‘ . esc_html($game[‘title’]) . ‘ ‘ . esc_html($game[‘discount_price’]) . ‘ ‘ . esc_html($game[‘original_price’]) . ‘

‘;
} else {
echo ‘

暂无折扣游戏信息。

‘;
}
}
// 添加短代码 [nintendo_discounts]
add_shortcode(‘nintendo_discounts’, ‘nintendo_eshop_discounts’);
?>


[nintendo_discounts]