Search code examples
phpcodeigniterframeworkssubmenu

how to add two or more urls to active class for sub menu with php?


<?php echo (uri_string() == 'user/profile') ? 'm-submenu__item--active' : ''; ?>

I want to add 'user/profile' and 'user/setting' or more url into this line.How can i do it using only this php line.


Solution

  • You could try in_array method

    <?php echo in_array(uri_string(), ['user/profile', 'user/setting']) ? 'm-submenu__item--active' : ''; ?>