Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
better title, added tags
Link
mickmackusa
  • 49.2k
  • 13
  • 98
  • 165

In PHP, how do you change the key of Replace keys in an array element?based on another lookup/mapping array

Rollback to Revision 1
Source Link
Thomas Owens
  • 116.5k
  • 100
  • 322
  • 439

Change all keys (numeric ids) In PHP, how do you change the key of an array to human-readable stringselement?

I have an associative array wherein the keys are numeric ID numbersform (they arekey => value where key is a numerical value, however it is not a sequential / indices),numerical value. The key is actually an ID number and the values are "count" integersvalue is a count.

  This is a suitable formatfine for most instances, however I want a function that gets the human-readable name from anotherof the array and uses that for the key (while maintaining the original relationship to, without changing the count values)value.

I didn't see a function that does this, but I'm assuming I need to provide the old key and new key (both of which I have) and transform the array. Is there an efficient way of doing this?

Change all keys (numeric ids) of an array to human-readable strings

I have an associative array where the keys are numeric ID numbers (they are not a sequential / indices), and the values are "count" integers.

  This is a suitable format for most instances, however I want a function that gets the human-readable name from another array and uses that for the key (while maintaining the original relationship to the count values).

I didn't see a function that does this, but I'm assuming I need to provide the old key and new key (both of which I have) and transform the array. Is there an efficient way of doing this?

In PHP, how do you change the key of an array element?

I have an associative array in the form key => value where key is a numerical value, however it is not a sequential numerical value. The key is actually an ID number and the value is a count. This is fine for most instances, however I want a function that gets the human-readable name of the array and uses that for the key, without changing the value.

I didn't see a function that does this, but I'm assuming I need to provide the old key and new key (both of which I have) and transform the array. Is there an efficient way of doing this?

Better title for the task, some rewording in body for clarity, added tags
Source Link
mickmackusa
  • 49.2k
  • 13
  • 98
  • 165

In PHP, how do you change the key Change all keys (numeric ids) of an array element?to human-readable strings

I have an associative array inwhere the formkeys are numeric ID numbers key => value where key is a numerical value, however it is(they are not a sequential numerical value. The key is actually an ID number/ indices), and the value is a countvalues are "count" integers. 

This is finea suitable format for most instances, however I want a function that gets the human-readable name of thefrom another array and uses that for the key, without changing (while maintaining the valueoriginal relationship to the count values).

I didn't see a function that does this, but I'm assuming I need to provide the old key and new key (both of which I have) and transform the array. Is there an efficient way of doing this?

In PHP, how do you change the key of an array element?

I have an associative array in the form key => value where key is a numerical value, however it is not a sequential numerical value. The key is actually an ID number and the value is a count. This is fine for most instances, however I want a function that gets the human-readable name of the array and uses that for the key, without changing the value.

I didn't see a function that does this, but I'm assuming I need to provide the old key and new key (both of which I have) and transform the array. Is there an efficient way of doing this?

Change all keys (numeric ids) of an array to human-readable strings

I have an associative array where the keys are numeric ID numbers (they are not a sequential / indices), and the values are "count" integers. 

This is a suitable format for most instances, however I want a function that gets the human-readable name from another array and uses that for the key (while maintaining the original relationship to the count values).

I didn't see a function that does this, but I'm assuming I need to provide the old key and new key (both of which I have) and transform the array. Is there an efficient way of doing this?

Question Protected by CommunityBot
Source Link
Thomas Owens
  • 116.5k
  • 100
  • 322
  • 439
Loading