php add to associative array
// for php 5.4+
$data += [$key => $value];
// for php 5.4-
$data += array($key => $value);
php add to associative array
// for php 5.4+
$data += [$key => $value];
// for php 5.4-
$data += array($key => $value);
Associative array in php
<?php
/*
There are 3 Types of array in php
1. Indexed arrays - Arrays with a numeric index
2. Associative arrays - Arrays with named keys
3. Multidimensional arrays - Arrays containing one or more arrays
This is the second one - Associative arrays
*/
$age = array("Samy"=>"35", "Naveen"=>"37", "Amit"=>"43");
echo "Mr.Samy is " . $age['Samy'] . " years old.";
?>
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
how to add an array into an associative array in php
$data[$category][] = $item;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us