I have an array:
$countries = array(
"af" => "Afghanistan",
"ax" => "Åland Islands",
"al" => "Albania",
"dz" => "Algeria"
);
and some variables:
$as = "American Samoa";
$ad = "Andorra";
How do I combine the variables into the array while keeping the variable name as the key in the array?
You can use
compactto create an array out of your variables and then simply add the two arrays together:See it in action.