PHP: One item with class="active" in navbar created with foreach-loop

one text

Solution:

Here is your new navbar.php - this should work. This will add active class to the links (<a> elements)

<?php
include "/includes/pagearray.php";

foreach ($pages as $page) {
    echo '<li><a href="' . $page['slug'] . '" class="' . ((strpos($_SERVER['REQUEST_URI'], $page['slug'])) ? "active" : "") . '">' . $page['title'] . '</a></li>';
}

Source