Created
November 12, 2012 19:10
-
-
Save mdsahib/4061240 to your computer and use it in GitHub Desktop.
Shorthand to check value in array
This file contains 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
<?php | |
//this array maps the function with the get parameters | |
$functions = array ( | |
"action" => "do_actions" , | |
"filter" => "do_filters" | |
); | |
foreach ($_GET as $key=>$value) { | |
//check if this field is corresponding functions or not | |
if ( array_key_exists($key , $functions) ) { | |
call_user_func($functions[$key] , $key,$value); | |
} | |
} | |
function do_actions ($key , $value) { | |
//place your code here to play with this value | |
echo 'do_actions is called with ' . $key . 'and' . $value . "</br>"; | |
} | |
function do_filters ($key , $value) { | |
//place your code here to play with this value | |
echo 'do_filters is called with ' . $key . ' and ' . $value . "</br>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment