Outputting array contents as nested list in PHP

Posted by Mamadou on Stack Overflow See other posts from Stack Overflow or by Mamadou
Published on 2011-01-10T14:20:17Z Indexed on 2011/01/10 14:54 UTC
Read the original article Hit count: 104

Filed under:
|
|

I have the array $tab[1,2,3,4,5,6,7,8,9,10] and I would like to display it like this:

<ul>
  <li>
     <a href=""/>FIRST ELEMENT OF THE TAB ==> 1</a>
     <a href=""/>2ND ELEMENT OF THE TAB ==> 2</a>
 </li>
 <li>
     <a href=""/>3THIRD ELEMENT==> 3</a>
     <a href=""/>FORTH ELEMENT OF THE TAB ==> 4</a>
 </li>
 <li>
     <a href=""/>FIFTH ELEMENT==> 5</a>
     <a href=""/>SIXTITH ELEMENT OF THE TAB ==> 6</a>
 </li>

</ul>

How can I achieve this in PHP? I am thinking of creating a sub array with array_slice.

© Stack Overflow or respective owner

Related posts about php

Related posts about html