Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6535867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:25:24+00:00 2026-05-25T10:25:24+00:00

Edit (Some background): I am dealing with some data for states/regions/etc within a country.

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:25:25+00:00Added an answer on May 25, 2026 at 10:25 am

    Just use the same variable for both parameters of array_combine():

    $arr = array_combine($arr, $arr);
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use Emacs to edit some VB6 files but Emacs does
I want to display and edit some objects in a WPF data grid and
More often than I like when designers edit some of our sites' pages, they
I am using the flex datagrid to allow the user to edit some data.
I want to copy my NSDictionary's data into plist and also edit some data
I am using sqlite in my app, i want to edit some data in
EDIT: Update - scroll down EDIT 2: Update - problem solved Some background information:
Within my application I am setting up some actions to allow users to create/edit/delete
I need to manually edit some of the files inside of the .cmp file
I am supposed edit some code for an assignment, and he gave us the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.