php add item to array
snippet in php

php append to array

user3333

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

php array add

user432

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

php add item to array

user5132

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

php append element to array

user7905

array_push($cart, 13);

add item to array in php

user1233

<?php

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

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

print_r($a);
?>

how to insert array php

user911


<?php

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

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

print_r($a);
?>