PHP - Adding values to an array

From MyWiki
Jump to: navigation, search
<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
?>

print_r prints a variable in human readable format
Popping the last item of an array

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