mardi 4 août 2015

foreach every 3 put inside a new ul

Actually I have this foreach loop:

<ul>
    <?php foreach ( $tasks as $task ) { ?>
        <li>
            ...
        </li>
    <?php } ?>
</ul>

It returns:

<ul>
    <li>...</li>
    <li>...</li>
    <li>...</li>
    <li>...</li>
    ...
</ul>

Now I need to change the loop to put every 3 <li> into a new <ul>, so I can have:

<div>
    <ul>
        <li>...</li>
        <li>...</li>
        <li>...</li>
    </ul>
    <ul>
        <li>...</li>
        <li>...</li>
        <li>...</li>
    </ul>
    ...
</div>

How I have to modify the foreach loop to achieve that result?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire