php array add
snippet in php

php append to array

user2163

$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

user4920


<?php

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

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

print_r($a);
?>
 

php array add

user6284

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

array_push php

user1637


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

php append element to array

user1625

array_push($cart, 13);

add item to array in php

user8323

<?php

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

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

print_r($a);
?>