“array_push” Kode Jawaban

PHP ditambahkan ke 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]
Allen

tambahkan item ke array dalam php

<?php

$a=array("red","green");

array_push($a,"blue","yellow");

print_r($a);
?>
Dark Dugong

Tambahkan array ke array php

<?php
$array1 = array("color" => "red", 2, 4);
$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
$result = array_merge($array1, $array2);
/*
Array
(
    [color] => green
    [0] => 2
    [1] => 4
    [2] => a
    [3] => b
    [shape] => trapezoid
    [4] => 4
)
*/
?>
Vast Vulture

array_push

array_push($array,$value);
Scary Shark

array_push

// The array_push() function inserts one or more elements to the end of an array.

$a=array("red","green");
array_push($a,"blue","yellow");
print_r($a);
Scary Shark

array_push

<?php
$a=array("red","green");
array_push($a,"blue","yellow");
print_r($a);

Array ( [0] => red [1] => green [2] => blue [3] => yellow )
?>
Prickly Piranha

Jawaban yang mirip dengan “array_push”

Pertanyaan yang mirip dengan “array_push”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya