array_push in php
snippet in php

php append to array

user7889

$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

user2478


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

php add item to array

user2302

<?php
  $z = ['me','you', 'he'];
  array_push($z, 'she', 'it');
  print_r($z);
?>

php append element to array

user2449

array_push($cart, 13);

array_push in php

user6881

<?php
// Insert "blue" and "yellow" to the end of an array:


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

array_push in php

user1762


<?php

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

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

print_r($a);
?>