Comparing string with "enumeration" of strings in php -


i wanna compare string "enumeration", can simplier in solution bellow? first know enum type not implemented in php.
problem question is: string s equal 1 of strings? since php don't have enum, values of enum in array or that.

 //$min_s string value of minute value example "15". if((strcmp($min_s, "00")== 0 || str_cmp($min_s,"15") == 0 ||             strcmp($min_s, "30")== 0 || strcmp($min_s, "45") == 0) { // ok}

goal:
make ifs more readable specific example , others in future when wanna compare string "enum".

to answer question literally:

$fifteens = array('00', '15', '30', '45'); if (in_array($min_s, $fifteens)) {     ... } 

but use arithmetic:

if ($min_s % 15 == 0) {     ... } 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -