array_push
snippet in php

php append to array

user3473

$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]

array push php

user3889


<?php

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

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

print_r($a);
?>
 

php array add

user1974

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

array_push php

user3389


<?php
$cesta = array("laranja", "morango");
array_push($cesta, "melancia", "batata");
print_r($cesta);
?>

array_push

user5917

$array[$key] = $value;
// or
$array[] = $value;
// or
array_push($array, [ mixed $... ]);

php append element to array

user4661

array_push($cart, 13);