SCook Posted August 23, 2007 Share Posted August 23, 2007 Hi gang, I would like to rename a key in an array from x to y for example, how is this done? Quote Link to comment https://forums.phpfreaks.com/topic/66277-renaming-an-array-key/ Share on other sites More sharing options...
btherl Posted August 23, 2007 Share Posted August 23, 2007 $a['new_key'] = $a['old_key']; unset($a['old_key']); Because php uses copy on write, this will not make a second copy of the data. Quote Link to comment https://forums.phpfreaks.com/topic/66277-renaming-an-array-key/#findComment-331496 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.