我有一个自定义电视时间表,我使用静态<table>. 每个<tr>都有 5 个<td>孩子,每个孩子按以下顺序包含以下内容之一:日期、时间、比赛、比赛和电视频道。
<table>
  <tr><th>DATE</th><th>TIME</th><th>COMPETITION</th><th>MATCH</th><th>CHANNEL</th></tr>
  <tr class="comp-1 ch-1">
    <td>October 17</td>
    <td>5 PM</td>
    <td></td>
    <td>Team Alpha v Team Bravo</td>
    <td></td>
  </tr>
</table>
我有以下内容PHP Array:
<?php
  $comps = [
    'comp-1' => 'Tug-of-War',
    'comp-2' => 'Tag Rugby',
    'comp-3' => 'Handball',
    'comp-4' => 'The Gauntlet',
  ];
  $channels = [
    'ch-1' => 'Channel 1',
    'ch-2' => 'Channel 2',
    'ch-3' => 'Channel 3',
    'ch-4' => 'Channel 4',
  ];
?>
我想要做的是让空<td>单元格根据<tr>其父级的class属性值自动填充。出于 XML、SEO 和 OGP 的目的,我需要在 PHP 中执行此操作。以前,它是使用 jQuery 完成的,但使用Google 的 Rich Snippets Testing Tool进行的测试表明,<td>当页面加载时,空单元格被读取为空。
如果有人可以帮助我对如何实现这一点有任何想法,我将不胜感激!