I have the following array
$data = array('key1'=>'val1',
              'key2'=>'val2',
              'key3'=>'val3'
             );
I would like to add to the开发者_Python百科 array.
$moreval = array('key4'=>'val4');
You can use array_merge for this.
$data=array_merge($data, array('key4'=>'val4'));
If this wasn't associative, you could use array_push.
you could just use:
$data['key4'] = 'val4';
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论