php +1每套内容

I'm creating a series of content blocks. (4 in total).

It's stupid to create all for of them if you can let php create them for you. So I created the first one and wrote a for loop that adds the content as long as it haven't a max number of 4.

Here it is:

<table>
<tr>
<?php 
    $counter =0;
    for ($i=0; $i <= 3; $i++){
        $counter++;
        ?>
        <td>some content to repeat with id='$id++' and '$id++'</td>
        <?php
    if ($counter == 2){
        echo '</tr><tr>';
        $counter=0;
    }
}
?>
</tr>
</table>

What this does is repeat the <td> two times and then end the rule and start a new one. Do this until you reach an amount of 4 (3 because 1=0)

The problem I have is that some of the content contains id's
The id's should also number up but only if the complete loop is repeated.
So $i++ should both have the same value if the loop runs once

So that would mean that if there are two id's in the first run they should both have the id1 and the next repeat should have id2

I have no idea how to do this.

The output should be:

<table>
    <tr>
        <td>
           This content has id 1   
           And this content has id 1 to    
        <td>
        <td>
           This content has id 2   
           And this content has id 2 to 
        <td>
    </tr>
    <tr>
        <td>
           This content has id 3   
           And this content has id 3 to 
        <td>
        <td>
           This content has id 4   
           And this content has id 4 to 
        <td>
    </tr>
</table>

M.

How about this

<table>
<?php 
    $id = 1
    for ($i=0; $i < 2; $i++){
        echo '<tr>';
        for ($j=0; $j < 2; $j++){
            echo 'This content has id $id';
            echo' And this content has id $id too';
        }
        $id += 1;
        echo '</tr>';
    }
}
?>
</table>

Update: added an id counter.

Is this what you mean? You don't need $counter as you have $i keeping count for you.

<table>
    <tr>
        <?php for ($i=0; $i <= 3; $i++){ ?>
            <td<?php
                if ($i < 2) echo ' id="1"';
                else echo ' id="2"';
            ?>>some content to repeat</td>
            <?php if ($i == 1){ echo '</tr><tr>'; } ?>
        <?php } ?>
    </tr>
</table>