php array push associative code example
Example 1: php append to array
$myArr = [1, 2, 3, 4];
array_push($myArr, 5, 8);
print_r($myArr);
$myArr[] = -1;
print_r($myArr);
Example 2: php add to associative array
$data += [$key => $value];
$data += array($key => $value);
Example 3: array_push php
<?php
$cesta = array("laranja", "morango");
array_push($cesta, "melancia", "batata");
print_r($cesta);
?>
Example 4: php array push
array_push ( array &$array [, mixed $... ] ) : int
or
$array[] = $var;
Example 5: php add to existing associative array
$a1=['aa'=>'123' , 'bb'=>'454'];
$a1 = array_merge( $a1 , ['a'=>1,'b'=>2] ) ;
Example 6: array_push php
<?php
$array[] = $var;
?>