This article mainly introduces the pushing and popping of linear tables in PHP, and analyzes the related techniques of pushing and popping linear tables in PHP with examples. I hope to be helpful.
The details are as follows:
<?php $stack = array("Simon", "Elaine"); //定义数组 array_push($stack, "Helen", "Peter"); //入栈 print_r($stack); ?>
##
<?php $stack = array("Simon", "Elaine"); //定义数组 array_unshift ($stack, "Helen", "Peter"); //入栈 print_r($stack); ?>
<?php $stack = array("Simon", "Elaine", "Helen", "Peter"); echo array_pop($stack)."/n"; //出栈 print_r($stack); ?>
<?php $stack = array("Simon", "Elaine", "Helen", "Peter"); echo array_shift($stack)."/n"; //出栈 print_r($stack); ?>
Related recommendations:
A brief analysis of the principle and simple implementation of linear tables
PHP implements the sequential storage structure of linear tables
php implements data structure linear table (sequential and chained)_PHP tutorial
The above is the detailed content of Detailed explanation of pushing and popping linear tables in PHP. For more information, please follow other related articles on the PHP Chinese website!