tags:

views:

27

answers:

1

ok so i have this array and i need to loop through

 <?php foreach($classes as $class){ ?>

the html needs to look like this

<li class="active"><span class="l"></span><a href="#">Standard Class</a><span class="r"></span></li>
<li><span class="l"></span><a href="#">Business Class</a><span class="r"></span></li>
<li><span class="l"></span><a href="#">Premium</a><span class="r"></span></li>

see the first one is active ...how do i make the first on active

the array data is

Array ( 
[0] => Array ( 
   [class] => Standard )
[1] => Array ( 
   [class] => Business ) 
[2] => Array ( 
   [class] => Premium ) ) 
+2  A: 

There may be better ways of course (depending on you class-structure, ...)

for($i = 0; i < count($classes); i++)
{
    echo "<li ";
    if($i == 0)
    {
        echo "class=\"active\"";
        // first one
    }
    echo "><span.....";
}
Fge