Edit (Some background):
I am dealing with some data for states/regions/etc within a country. The data looks like so (essentially translated to english and its original form in the local language):
Array
(
['Anhui'] => "安徽省",
...etc
)
Now that’s all fine and well if I am displaying the data to someone from China. However, if the visitor is from another country, it is clearly better to display the english name (Anhui). This is essentially the point of this exercise.
The data is then used to generate a drop down to set the value and options.
I have an array that looks like so:
Array
(
[0] => "item1"
[1] => "item2"
[2] => "item3"
)
I would like to turn this into an associate array:
Array
(
["item1"] => "item1"
["item2"] => "item2"
["item3"] => "item3"
)
Are there any ways to do this besides using a foreach loop?
Just use the same variable for both parameters of
array_combine():However, I don’t really see the point of this. Perhaps you could explain what you are trying to accomplish, so you could find the best solution.