I have the following array
$data = array('key1'=>'val1', 'key2'=>'val2', 'key3'=>'val3' );
I would like to add to the array.
$moreval = array('key4'=>'val4');
You can use array_merge for this.
$data=array_merge($data, array('key4'=>'val4'));
If this was not associative, you can use array_push .
you can just use:
$ data ['key4'] = 'val4';
Source: https://habr.com/ru/post/1785107/More articles:Would an immutable keyword in Java be a good idea? - javaWhere in Maven should multiple domain and persistence classes go through? - javaNSTableView Drag and Drop not working - objective-cHow do you deal with breaking changes in Rails migration? - ruby-on-railsHow to ensure that the image is filled? (in java) - javaПотоки POSIX и выход из потока - cПоказывать имя вместо идентификатора в отношении HABTM - ruby-on-rails-3How to implement a full duplex channel over TCP using a single thread? - socketsDo I need to end cout with a semicolon? - c ++Firebug - how to reduce indentation of nodes? - cssAll Articles