Je cherche un moyen de faire plus simple au niveau du if...
Code:
1
2
3
4
5
6
7
8
9
10 $var ="toto"; $var2 = "tutu"; $var3 = "titi"; $var4 = "tata"; if ($toto==$var | $toto==$var2 | $toto==$var3 |*$toto==$var4) { echo "..." }
Version imprimable
Je cherche un moyen de faire plus simple au niveau du if...
Code:
1
2
3
4
5
6
7
8
9
10 $var ="toto"; $var2 = "tutu"; $var3 = "titi"; $var4 = "tata"; if ($toto==$var | $toto==$var2 | $toto==$var3 |*$toto==$var4) { echo "..." }
Salut,
Tu peux utiliser in_array() pour rechercher si une valeur est contenue dans un tableau :
Code:
1
2
3
4 if (in_array($toto, array($var, $var2, $var3, $var4))) { echo "..."; }