Add values to an associative array in PHP

前端 未结 2 1013
花落未央
花落未央 2020-12-29 18:26

I want to append an element to to end of an associative array.

For example, my array is

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


        
2条回答
  •  悲&欢浪女
    2020-12-29 19:29

    Just add it like you would with a non-associative array:

    $test = array('chemical' => 'asdasd', 'chemical_hazards' => 'ggggg'); //init
    $test['solution'] = 'good';
    

提交回复
热议问题