Answers for "append value in assosiative array php"

PHP
4

php add to associative array

// for php 5.4+
$data += [$key => $value];

// for php 5.4-
$data += array($key => $value);
Posted by: Guest on October-26-2020
1

php add to existing associative array

$a1=['aa'=>'123' , 'bb'=>'454'];

$a1 = array_merge( $a1 , ['a'=>1,'b'=>2] ) ;
Posted by: Guest on January-11-2021
0

how to add an array into an associative array in php

$data[$category][] = $item;
Posted by: Guest on July-25-2021

Browse Popular Code Answers by Language