View Full Version : Remove keys from an array but keep values in order

07-10-2012, 10:02 PM
I have an array that I create in wordpress using some custom post types, and because I can't figure out how to actually get it to sort by the dates associated with that post type, I've stored them all into an array, using their timestamp as their key value, and then sorted on the key, no problem.

The issue is when I go ahead and loop though this newly sorted array, I need to know what the current item in the loop is and what if any the next item is. Because of that, I'm trying to figure out how I can drop all the key values so it defaults back to the basic 0, 1, 2, 3, ...

Anyone know how I can do this? If I'm overthinking this or there is a better solution? I could make an array of the keys and then loop though them as well and create a second associative array but I feel like its the wrong way to go. Anyone have any suggestions for me?

07-10-2012, 10:57 PM
Of course, even though I was using the array_keys to come up with a alternate solution, it just didn't click... if array_keys gets the arrays keys... maybe array_values will get the array's values!