Brand new to php and I want to say "if dc is equal to ABC or DEF. In php, is it: if ($dc == "ABC"|"DEF")
Asked
Active
Viewed 37 times
-1
-
It's more like _if dc is equal to ABC or dc is equal to DEF_ – Spoody Jul 30 '18 at 18:38
-
if ($dc == "ABC" || $dc == "DEF"), but you also may use in_array as suggested below. You could search for it, you could find so many good options. – MyLibary Jul 30 '18 at 18:50
1 Answers
1
You can use in_array.
if(in_array($dc, ["ABC", "DEF"])){
// One of them is in $dc
}
In_array returns true if the needle ($dc) is found in the array.

Andreas
- 23,610
- 6
- 30
- 62