J. Doe J. Doe - 1 year ago 56
PHP Question

Array not working

I need help with

because it's not working for some reason.

if(isset($_GET["page"]) && $_GET["page"] == array("i_gebruikers","gebruikerslijst","nieuwegebruiker","ban")) {
<a href="index.php?page=i_gebruikers"><li class="active">Gebruikers</li></a>
<?php } else { ?>
<a href="index.php?page=i_gebruikers"><li>Gebruikers</li></a>
<?php } ?>

As you can see I'm trying to make a button which has the
class when you're on a page defined in the array. However it's completely ignoring the array.

Please help me out, it's very much appriciated!


You are essentially checking if the value of both counts of $_GET are equal to the full array of items, which they are likely not.

if(isset($_GET['page']) && in_array($_GET['page'], array("i_gebruikers","gebruikerslijst","nieuwegebruiker","ban"))) {


Should work just fine.