Getting last role when counting user with certain roles
-
I have this code that count the amount of user with certain roles and displays the amount in a list, which works fine.
But now I want to add a last class to the last list item, which doesn’t work.This is the code I have sofar:
$result = count_users(); $show = array('trainer', 'sportvereniging', 'sportschool'); foreach($result['avail_roles'] as $role => $count){ if( in_array($role, $show)) { if ($role == (count($result) - 1)) { echo 'last'; } echo '<li><span class="count-num">' . $count . '</span><br><span class="count-group">' . $role, 's</span></li>'; } } echo '</ul>';
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Getting last role when counting user with certain roles’ is closed to new replies.