push both key and value onto an array

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
tores
Forum Contributor
Posts: 120
Joined: Fri Jun 18, 2004 3:04 am

push both key and value onto an array

Post by tores »

Hi

I know it's possible to push a value onto an existing array, with array_push. But then the keys are set automatically. I want to push the value for the key also. Anyone know if, and how, this can be done?

Regards tores
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$arr[$key] = $value;
Post Reply