好的,所以我有这个数组,我需要循环
<?php foreach($classes as $class){ ?>
html需要看起来像这样
<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>
看第一个是活跃的...我如何在活跃的
上创建第一个数组数据
Array (
[0] => Array (
[class] => Standard )
[1] => Array (
[class] => Business )
[2] => Array (
[class] => Premium ) )
答案 0 :(得分:2)
当然可能有更好的方法(取决于你的班级结构......)
for($i = 0; i < count($classes); i++)
{
echo "<li ";
if($i == 0)
{
echo "class=\"active\"";
// first one
}
echo "><span.....";
}