Difference between revisions of "PHP - Adding values to an array"

From MyWiki
Jump to: navigation, search
 
Line 9: Line 9:
 
print_r prints a variable in human readable format<br>
 
print_r prints a variable in human readable format<br>
 
Popping the last item of an array
 
Popping the last item of an array
<source lang="php>
+
<source lang="php">
  
 
<?php
 
<?php

Latest revision as of 12:55, 4 April 2019

<?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);
?>