I'd like to add a class to the first result of a query inside a foreach and then echo the rest of the information.
I am using the following code to retrieve and show only the first result
foreach ($highlightedArticles as $data)
{
$article_title = $data['article_title'];
$article_image = $data['article_image'];
echo '
<section class="headlines">
<h2 class="heading orange">
<a href="#">news</a>
</h2>
<ul>
<li class="first">
<a href="">
<figure>
<img src="url/'.$article_image.'"/>
<figcaption>'.$article_title.'</figcaption>
</figure>
</a>
</li>
</ul>
</section>
';
}
The issue that I cannot resolve now is how to add the rest of the results(4 resulsts total with the class"first") since everything is inside an echo and I need to add the results that are in a < li >
.
This is what I would like to show..
<ul>
<li class="first">
<a href="">
<figure>
<img src="url/'.$article_image.'"/>
<figcaption>'.$article_title.'</figcaption>
</figure>
</a>
</li>
<li>another result</li>
<li>another result</li>
<li>another result</li>
</ul>