php add variable to array
snippet in php

php add variable to array

user2329

<?php
	$myArray = array(); // Init empty array

	$myArray[] = $value; // Add value to the array
?>

php array add

user2816

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

php add item to array

user6218

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

php add element to array

user6448


<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
?>