Created
February 8, 2015 20:13
-
-
Save datamafia/dae1c97221b4b5893a05 to your computer and use it in GitHub Desktop.
Using switch statement and additional evaluation in php super short demo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Switch statment + additional eval | |
ini_set('display_errors',1); | |
$arr = array( | |
'match', | |
'other' | |
); | |
x($arr); | |
function x($a){ | |
switch($a[0]){ | |
// order matters | |
case 'match' && $a[1]=='other': | |
echo 'match-other'; | |
break; | |
case 'match': | |
echo 'match'; | |
break; | |
} | |
} | |
// match-other |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment