“array_push” Código de respuesta

PHP Agregar a la matriz

$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

Agregar elemento a la matriz en PHP

<?php

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

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

print_r($a);
?>
Dark Dugong

Agregar matriz a la matriz 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

Respuestas similares a “array_push”

Preguntas similares a “array_push”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código