Answers for "best way to add object in array php"

PHP
4

array push object php

$myArray = [];

array_push($myArray, (object)[
        'key1' => 'someValue',
        'key2' => 'someValue2',
        'key3' => 'someValue3',
]);

return $myArray;
Posted by: Guest on March-05-2021
3

add object in array php

$myArray = array("name" => "my name");
echo json_encode($myArray);
Posted by: Guest on April-27-2020

Code answers related to "best way to add object in array php"

Browse Popular Code Answers by Language