在php中显示一行中的2张图像,并为下一张图像开始新的行


show 2 images in a row and the start a new row for next image in php

我试图在一行中显示2个图像。目前,当显示一个图像时,下一个图像会转到新行。我想要的是,当2个图像显示在一行中时,它应该转到下一行。

for($i = 0; $i < $counter; $i++)
        {
            $path = "http://verfix.com/playground_app/assets/images/upload/".$data['inspection'][$i]->image;

        $toolcopy .= '<tr style"height:350px;"> 
                <td style="width:100px;">
                    P-'.$data['inspection'][$i]->id.'
                </td>
                <td style="width:420px;">
                    <img src="'.$path.'"  width="420" height="220">
                </td>
                </tr>';
        }
        $toolcopy .= '</table>[![enter image description here][1]][1]

谢谢你的帮助

试试下面的代码,应该能成功。

    $toolcopy = '<table>';
    for($i = 0; $i < $counter; $i++)
    {
        $path = "http://verfix.com/playground_app/assets/images/upload/".$data['inspection'][$i]->image;
            if($i === 0 || $i % 2 === 0) {
                if($i > 0) $toolcopy .= '</tr>';
                $toolcopy .= '<tr style"height:350px;">';
            }
            $toolcopy .= '
            <td style="width:100px;">
                P-'.$data['inspection'][$i]->id.'
            </td>
            <td style="width:420px;">
                <img src="'.$path.'"  width="420" height="220">
            </td>';
    }
    $toolcopy .= '</tr>';
    $toolcopy .= '</table>';[![enter image description here][1]][1]

它将两个图像放在同一TR中的两个独立的TD元素中,下两个图像放在下一行,依此类推。