Creating my loading screen on garrys mod, and seeing this "useless" coding, and was betting that there is a way to shorten it massively, however I am quite a php nooby and was wondering if there was a perhaps a way to use arrays or something to make it easier/shorter? Code Here
Asked
Active
Viewed 56 times
-1
-
I do recommend you to at least put all the cases where $map = " "; in a comment for later reference. – Lexib0y Feb 14 '15 at 17:17
-
Consider a `switch` statement. All the `$map = " ";` lines can be part of the `default` `case`. – ceejayoz Feb 14 '15 at 17:32
1 Answers
3
$array = array(
"gm_flatgrass" => "Flatgrass",
"cs_assault" => "CS Assault",
"de_train" => "",
...
);
$getmap = $_GET['mapname'];
if(array_key_exists($getmap,$array)) {
$map = $array[$getmap];
}

kidA
- 1,379
- 1
- 9
- 19