Simplifier un if ?
analog101
Messages postés
173
Date d'inscription
Statut
Membre
Dernière intervention
-
avion-f16 Messages postés 19268 Date d'inscription Statut Contributeur Dernière intervention -
avion-f16 Messages postés 19268 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Et-il possible de simplifier le if ?
if (($id == 1866) || ($id == 3085) || ($id == 2945) || ($id == 1385))
{
..
}
Merci!
Et-il possible de simplifier le if ?
if (($id == 1866) || ($id == 3085) || ($id == 2945) || ($id == 1385))
{
..
}
Merci!
2 réponses
Salut,
https://www.php.net/manual/fr/function.in-array.php
<?php
$allowed = array(1866, 3085, 2945, 1385);
if(in_array($id, $allowed)) {
}
https://www.php.net/manual/fr/function.in-array.php