php add to associative array
// for php 5.4+ $data += [$key => $value]; // for php 5.4- $data += array($key => $value);
Source: stackoverflow.com
php add to existing associative array
$a1=['aa'=>'123' , 'bb'=>'454']; $a1 = array_merge( $a1 , ['a'=>1,'b'=>2] ) ;
php add new item to associative array
$a = array('foo' => 'bar'); // when you create $a['Title'] = 'blah'; // later
Source: www.sitepoint.com
array_push php
// array_push ( array &$array [, mixed $... ] ) : int // array_push() treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables pushed. Has the same effect as: <?php $array[] = $var; ?> // repeated for each passed value. // Note: If you use array_push() to add one element to the array, it's better to use $array[] = because in that way there is no overhead of calling a function.
php array push
If you're going to use array_push() to insert a "$key" => "$value" pair into an array, it can be done using the following: $data[$key] = $value; It is not necessary to use array_push.
Source: www.php.net
how to push associative array in php
$arr = array( "name" => "jonh", "Mob" => "588555", "Email" => "jonh143@gmail.com" ); $arr['Country'] = "United State";
Source: wlearnsmart.com