Home  >  Article  >  Backend Development  >  Detailed explanation of pushing and popping linear tables in PHP

Detailed explanation of pushing and popping linear tables in PHP

*文
*文Original
2017-12-28 15:53:571796browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn