Answers for "add array function"

PHP
68

php append to array

$myArr = [1, 2, 3, 4];

array_push($myArr, 5, 8);
print_r($myArr); // [1, 2, 3, 4, 5, 8]

$myArr[] = -1;
print_r($myArr); // [1, 2, 3, 4, 5, 8, -1]
Posted by: Guest on January-21-2020
2

array insertion javascript

Array.prototype.insert = function ( index, item ) {
    this.splice( index, 0, item );
};
Posted by: Guest on May-04-2020
3

add object in array php

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

how to insert a value into an array javascript

var list = ["foo", "bar"];


list.push("baz");


["foo", "bar", "baz"] // result
Posted by: Guest on March-09-2020

Code answers related to "add array function"

Browse Popular Code Answers by Language