I need to a perform an action based on the value of a string
. I think that if I use a switch
statement it will be slower than using multiple if
s and strcmp
function. Thoughts?
Method 1:
switch ( $string ){
case 'Hello': //do stuff
break;
case 'Howdy': //do stuff
break;
}
Method 2:
if ( strcmp($string, 'Hello') == 0 ) // do stuff
if ( strcmp($string, 'Howdy') == 0 ) // do stuff
Which one will be most effective?