“array_push” Réponses codées

PHP Ajouter au tableau

$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

Ajouter un élément au tableau en php

<?php

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

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

print_r($a);
?>
Dark Dugong

Ajouter le tableau à la table 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

Réponses similaires à “array_push”

Questions similaires à “array_push”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code