Answers for "php add element object to array"

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
2

php add element to array

<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
?>
Posted by: Guest on October-12-2020

Browse Popular Code Answers by Language