Answers for "push array associative in php"

PHP
5

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
0

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.
Posted by: Guest on December-13-2021

Code answers related to "push array associative in php"

Browse Popular Code Answers by Language