简单的HTML DOM解析器.删除表中的第一行,然后删除每个表的第二列


Simple HTML DOM Parser. Remove first row in table and then remove second column of each

我试图解析一个HTML字符串,这是一个表。我设法移走了桌子的第一排。然后我如何删除表中的第二列?

我像这样删除第一行:

$preparsed = "<div style='border:1px #CCCCCC dotted; padding:5px'><div style=''>
              <div id='divPrint'>         
                  <table cellpadding='5' cellspacing='0' width='886'>
                  <tr bgcolor='#666666' class='normal' style='color:#FFFFFF; font-weight:bold;'>
                      <td width='100px' style='font-size:11px;'><b>Type</b></td>
                      <td width='110px' style='font-size:12px;'><b>Date</b></td>
                      <td width='100px' style='font-size:12px;'><b>Details</b></td>
                      <td width='140px' style='font-size:12px;'><b>Instructor</b></td>
                      <td width='140px' style='font-size:12px;'><b>Student / Client</b></td>
                      <td style='font-size:12px;'><b>Comment</b></td>
                  </tr>
                  <tr class='normal' style='font-size:11px' bgcolor='#EEEEEE'>
                    <td style='font-size:12px;'>Training</td>
                    <td style='font-size:12px;'>2016-10-05 <br /><i class='small'>(16:00:00-18:00:00)</i></td>
                    <td style='font-size:12px;'>Zara</td>
                    <td style='font-size:12px;'>Gary</td>
                    <td style='font-size:12px;'>Alfred</td>
                    <td style='font-size:12px;'></td>
                   </tr><tr class='normal' style='font-size:11px' bgcolor='#FFFFFF'>
                    <td style='font-size:12px;'>Training</td>
                    <td style='font-size:12px;'>2016-10-05 <br /><i class='small'>(12:00:00-15:00:00)</i></td>
                    <td style='font-size:12px;'>Zara</td>
                    <td style='font-size:12px;'>Gary</td>
                    <td style='font-size:12px;'>shawn</td>
                    <td style='font-size:12px;'></td>
                   </tr>
                  </table>
              </div>
              </div></div>";
$html = new simple_html_dom();
$html->load($preparsed);
$rows = array_slice($html->find('tr'), 1);
foreach ( $rows as $element ) {
echo '<h3>'. $element->plaintext . '</h3>';

删除第一行。我怎样才能a)首先删除每一行的第二列(日期),或者b)首先删除第一行,然后删除每一行的所有第二列?

像这样:

$html = new simple_html_dom();
$html->load($preparsed);
$rows = array_slice($html->find('tr'), 1);
foreach ( $rows as $element ) {
    echo '<h3>'. $element->plaintext . '</h3>';
    $cols = array_slice($element->find('td'), 2);
    foreach ( $cols as $col ) {
        echo '<h4>The second col os the row values '. $col->plaintext . '</h4>';
    }
}