add a variable to an array php code example
Example 1: array_push
$array[$key] = $value;
$array[] = $value;
array_push($array, [ mixed $... ]);
Example 2: php add element to array
<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
?>
Example 3: assign array to variable php
$info = array('coffee', 'brown', 'caffeine');
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";
list($drink, , $power) = $info;
echo "$drink has $power.\n";
list( , , $power) = $info;
echo "I need $power!\n";
list($bar) = "abcde";
var_dump($bar);