Shorten useless coding? [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
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

$array = array(
"gm_flatgrass" => "Flatgrass",
"cs_assault" => "CS Assault",
"de_train" => "",
...
);
$getmap = $_GET['mapname'];
if(array_key_exists($getmap,$array)) {
$map = $array[$getmap];
}

Related

Send array to JSON PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I got these arrays
$address = array("1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh", "12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT", "1dice6YgEVBf88erBFra9BHf6ZMoyvG88")
$amount= array("100000000","150000000","200000000")
and I want to convert them to json format like below:
{
"1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh": 100000000,
"12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT": 1500000000,
"1dice6YgEVBf88erBFra9BHf6ZMoyvG88": 200000000
}
I tried too much but couldn't figure out how to do that in PHP, any ideas?
Use array_combine:
echo json_encode(array_combine($address, array_map('intval', $amount)));

Wordpress is messing up .. help trouble shoot [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I wrote this..
<?php wp_nav_menu (array ( 'conaitner_class' => 'main-nav','container' => 'nav'));?>
but.. WordPress displays this code as
class="menu-main-nav-container"
The class is supposed to be .nav-conainer but wordpress adds "menu-main-" infront of it
The problem is that you have a typo: conaitner_class should be container_class:
wp_nav_menu (array ( 'container_class' => 'main-nav','container' => 'nav'));
Also, the way you are calling this, the class will end up being main-nav, not .nav-conainer. I'm not sure where you're getting the latter.

Add array to array without keys [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I know this must be a huge newbie question, but I didn't find the correct answer. Let's see. I have an array set:
$global_array = array();
Then, I want to add an arry inside $global_array, but I dont want the keys. So, the result I want to get is:
$global_array = array(
array(
'bla',
'bla'
)
);
Sorry for the noob question. Thanks!
This should help:
$global_array[] = array('bla','bla');
All arrays will have keys...
If not defined as default 0,1,2,3...

Easy way to fix global variables in PHP 5.4? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a project with lots global variables.
Examples used in functions
function ChangePassForm( $VARS ) {
global $tpl, $iBtns, $db;
...
$db->query("....");
}
I can pretty easy guess what the question is:
"Why is it not working"?
ANSWER from PHP.net:
Anyway I voted to close the question.
#Piotr please refine the question or it will be closed.

I want learn about the structure of Drupal [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
now I want learn about the structure of Drupal platform.Can you tell me the book for beginning ? I don't know what to begin, thanks.
Check this discussion. Also as #CIGuy suggested, take a look at Drupal structure.

Categories