Target the Last Item in a PHP foreach Loop
PHP
To target the last item in a PHP foreach loop without using a counter, check for count( $array ) -1
within the loop.
This simple example assigns appropriate classes to the rendered elements:
comments powered by Disqus