simple array manipulation

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
AudiS2
Forum Newbie
Posts: 5
Joined: Thu Feb 28, 2008 6:02 pm

simple array manipulation

Post by AudiS2 »

Let say I have an example array('color'=>'green', 'size'=>'big')

How can I insert 'weight'=>'heavy' at the beginning of array?

array_unshift would not accept 'weight'=>'heavy' as a parametar.
adroit
Forum Commoner
Posts: 37
Joined: Fri Aug 08, 2008 1:25 am
Location: India
Contact:

Re: simple array manipulation

Post by adroit »

You can use combination of array_fill_keys() and array_unshift() function.
Post Reply