Difference between revisions of "PHP - Adding values to an array"
From MyWiki
| (One intermediate revision by the same user not shown) | |||
| Line 8: | Line 8: | ||
</source> | </source> | ||
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 | ||
| + | <source lang="php"> | ||
| + | |||
| + | <?php | ||
| + | $stack = array("orange", "banana", "apple", "raspberry"); | ||
| + | $fruit = array_pop($stack); | ||
| + | print_r($stack); | ||
| + | ?> | ||
| + | </source> | ||
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); ?>