Answers for "add array to object php"

PHP
9

php convert array to object

$object = (object) $array;
Posted by: Guest on March-17-2020
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
1

convert array to object php

$arrayResult = array_map(function($array){
    return (object)$array;
}, $yourOrinalArray);
Posted by: Guest on July-17-2020
3

add object in array php

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

Browse Popular Code Answers by Language