Here are the 9
different Strings that I want to apply if else conditions(or something better
) for:
1. Automated - Under the Hood: iPhone 6 running iOS 9
2. Automated - AU/NZ: iPhone 6 running iOS 9
3. Automated - DRM: iPhone 6 running iOS 9
4. Automated - Ads regression: iPhone6 running iOS 9
5. Automated - Ads regression: iPhone 5 running iOS 8
6. Automated - UI & Functional Regression on iPad 2 running iOS 8
7. Automated - Under the Hood: iPad Air on iOS 8
8. Automated - AU/NZ: iPad Air running iOS 8
9. Automated - DRM iPadAir running iOS 8
Every time, I will get one of above string
and that will be assigned to a PHP variable
. It is possible that the order of words or position of few words in any string can change
. But certain things like OS, phone type, OS version and test type will not change
. Based on what specific words, a string contains, I will do a REST api call.
For example, if PHP var is holding the 1st string i.e if
$test = Automated - Under the Hood: iPhone 6 running iOS 9
, then I will make #1 rest api call.
So, the way I think I should do is this:
if ($test/string contains "under", "hood", "iPhone 6", "iOS 9") then do #1rest call (that i have command for)
else if ($test/string contains "AU", "NZ", "iPhone 6", "iOS 9") then do #2rest call..
....
else
... for all the above 9 strings.
So far I have tried .contains() in PHP. Will a switch be a better alternative to this? If yes, an example would be good to have.
Otherwise, better way to do in if-else conditions / regex.