Zomie Posted November 27, 2006 Share Posted November 27, 2006 I have a an array that uses a timestamp as the key:[code]Array( [1164606003] => Array ( [1] => 123 [2] => 456 [3] => 789 ) [1164604202] => Array ( [1] => 789 [2] => 456 [3] => 123)[/code]I would like to do a replace on the key so it looks like this:[code]Array( [1] => Array ( [1] => 123 [2] => 456 [3] => 789 ) [2] => Array ( [1] => 789 [2] => 456 [3] => 123)[/code]While maintaining its order, the only php functions I have found to replace the key comes with sort, which changes the order of the array.Is there a function I am missing or an easy way to do this? I apoligize I am fairly new to php, most of my background is in ColdFusion. Quote Link to comment Share on other sites More sharing options...
btherl Posted November 27, 2006 Share Posted November 27, 2006 http://sg.php.net/manual/en/function.array-merge.phpThis will work, providing your array is numerically indexed (that is, as long as those are ints and not strings). BUT, it will re-index starting with 0, not with 1. Do you need it to start at 1 rather than at 0?array_combine() may also be useful. Quote Link to comment Share on other sites More sharing options...
Zomie Posted November 27, 2006 Author Share Posted November 27, 2006 THAT WORKED, I just spent the last 9 hours trying to figure that damn thing out.Grrr thanks alot for the help! Quote Link to comment 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.