How can CSS be used to customize the spacing between table columns generated by PHP code?

To customize the spacing between table columns generated by PHP code, you can use CSS to target the table elements and adjust the padding or margin between the columns. By applying CSS styling to the table, th, and td elements, you can control the spacing and alignment of the columns to achieve the desired layout.

echo '<style>
    table {
        border-collapse: collapse;
        width: 100%;
    }
    th, td {
        padding: 10px; /* Adjust the padding to customize the spacing between columns */
        text-align: left;
        border-bottom: 1px solid #ddd;
    }
</style>';

echo '<table>';
echo '<tr>';
echo '<th>Column 1</th>';
echo '<th>Column 2</th>';
echo '</tr>';
echo '<tr>';
echo '<td>Data 1</td>';
echo '<td>Data 2</td>';
echo '</tr>';
echo '</table>';