replacing array keys

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

replacing array keys

Post by Luke »

OK... I have an array who's keys all have a prefix of "directory_". How would I traverse through that array and remove that prefix from the keys? Isn't there like an array_key_replace() function or something? I can't find it on php.net.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

This topic was just discussed a little bit ago. There is no way to "change" your array indeces. You can re-write them to new ones while destroying (or unsetting) the originals.

Check out the previous discussion at this topic.
Last edited by RobertGonzalez on Sat Nov 12, 2005 5:10 pm, edited 1 time in total.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Thanks :D
Post Reply