I have a client software program and in it I have a variable, can be used as a string, split, etc, which I want to use within an if statement.
So it may be A|B, in which case I want to run if(A|B)
It may be A|B|C, in which case I want to run if(A|B|C) and so on
I can’t use eval as
- it’s a bad thing, and
- their software blocks it
Any help appreciated.
I’ve tried splitting, rebuilding into a string, passing via another function, but it won’t play like I want it to.
Is there an easy solution to do this? Without using multiple if, else, or case statements ?
2
Answers
What do you mean "run if (A|B)"
The simplest is comparing using quotes, assuming you do not mean A OR B when you write A|B
You can archiev this via Array
some
along with Arrainclude
method like below :