simplify a big IF!

-1

I have the following condition to test:

if (isset($_GET["cadastrarMembro"]) && (
                   $_SESSION["acesso"]["idAcesso"] == 3 
                   $_SESSION["acesso"]["idAcesso"] == 5 
                   $_SESSION["acesso"]["idAcesso"] == 6 
                   $_SESSION["acesso"]["idAcesso"] == 10 
                                         ) {

//FAZ ALGO AQUI
}

I would like to simplify something like this:

if (isset($_GET["cadastrarMembro"]) && $_SESSION["acesso"]["idAcesso"] IN (3, 5, 6 , 10)) {
//FAZ ALGO AQUI
}

How to do this?

    
asked by anonymous 05.01.2019 / 19:35

1 answer

5
if (isset($_GET["cadastrarMembro"]) && in_array($_SESSION["acesso"]["idAcesso"], [3, 5, 6, 10])) {
//FAZ ALGO AQUI
}
    
05.01.2019 / 19:52