Answers for "insert new item in a array object 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
1

php insert in array

$original = array( 'a', 'b', 'c', 'd', 'e' );
$inserted = array( 'x' ); // not necessarily an array, see manual quote

array_splice( $original, 3, 0, $inserted ); // splice in at position 3
// $original is now a b c x d e
Posted by: Guest on June-04-2020

Code answers related to "insert new item in a array object php"

Browse Popular Code Answers by Language