-2

I have an IF statement that consists of many OR conditions I want to ask if there is anyway I can reduce the OR conditions by combining them into one statement instead of the multiple conditions

if (($request->payment_method == "Bank_Transfer") || ($request->payment_method  == "Credit/Debit Card")
        || ($request->payment_method == "POS") ){

        }
Paul
  • 263
  • 4
  • 21

1 Answers1

2

You can use in_array like below:

if (in_array($request->payment_method, ["Bank_Transfer", "Credit/Debit Card", "POS"])) {

}
Lovepreet Singh
  • 4,792
  • 1
  • 18
  • 36