1// for php 5.4+
2$data += [$key => $value];
3
4// for php 5.4-
5$data += array($key => $value);
1<?php
2/*
3There are 3 Types of array in php
41. Indexed arrays - Arrays with a numeric index
52. Associative arrays - Arrays with named keys
63. Multidimensional arrays - Arrays containing one or more arrays
7
8This is the second one - Associative arrays
9*/
10
11$age = array("Samy"=>"35", "Naveen"=>"37", "Amit"=>"43");
12echo "Mr.Samy is " . $age['Samy'] . " years old.";
13
14?>
1
2$a1=['aa'=>'123' , 'bb'=>'454'];
3
4$a1 = array_merge( $a1 , ['a'=>1,'b'=>2] ) ;
5