array push php
snippet in php

array push php

user4687


<?php

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

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

print_r($a);
?>
 

php append to array

user5500

$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

user9118

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

array_push php

user8798


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

array_push

user9227

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

php add item to array

user8885

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