tags:

views:

69

answers:

2

Hi,

I want to append an element into an associative array at the end.

for example

my array is

$test=Array ( [chemical] => asdasd [chemical_hazards] => ggggg )

and my result should be

$test=Array ( [chemical] => asdasd [chemical_hazards] => ggggg [solution] => good)

Could you guys tell me how to implement this.

thanks

+3  A: 

Just add it like you would normally:

$test = array('chemical' => 'asdasd', 'chemical_hazards' => 'ggggg'); //init
$test['solution'] = 'good';
musicfreak
Super, it worked thanks
Thinker
A: 

If you are looking for a way to insert a value into an arbitrary position in the array, and not only the end: This guy asked the same question today.

Pekka