Possible Duplicate:
Fastest way to add prefix to array keys?
I had a quick question about arrays in PHP. I need to add a couple of characters to each key in an array, for instance:
name => Mark age => 23 weight = > 150
needs to be converted to:
r_name => Mark r_age => 23 r_weight =>
150
Any help would be appreciated, thanks.
Iterate the array, add a new item with the modified key and delete the original item:
As
foreachworks with an internal copy of the array, you won’t run into an infinite loop.