Created
April 10, 2013 04:07
-
-
Save meishern/5351724 to your computer and use it in GitHub Desktop.
CASE / SWITCH - a faster and better way to do it with arrays
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
// used for $current_home = 'current'; | |
$group1 = array( | |
'home' => True, | |
); | |
// used for $current_users = 'current'; | |
$group2 = array( | |
'users.online' => True, | |
'users.location' => True, | |
'users.featured' => True, | |
'users.new' => True, | |
'users.browse' => True, | |
'users.search' => True, | |
'users.staff' => True, | |
); | |
// used for $current_forum = 'current'; | |
$group3 = array( | |
'forum' => True, | |
); | |
if(isset($group1[$p])) | |
$current_home = 'current'; | |
else if(isset($group2[$p])) | |
$current_users = 'current'; | |
else if(isset($group3[$p])) | |
$current_forum = 'current'; | |
else | |
user_error("\$p is invalid", E_USER_ERROR); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment