Home >Backend Development >PHP Tutorial >PHP linear table push and pop example analysis_PHP tutorial

PHP linear table push and pop example analysis_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:50:491299browse

Example analysis of pushing and popping PHP linear tables into and out of the stack

This article explains how to push and pop PHP linear tables into the stack. Share it with everyone for your reference. The details are as follows:

1

2

3

4

5

$stack = array("Simon", "Elaine"); //定义数组

array_push($stack, "Helen", "Peter"); //入栈

print_r($stack);

?>

1 2

3

4

5

1

2

3

4

5

$stack = array("Simon", "Elaine"); //定义数组

array_unshift ($stack, "Helen", "Peter"); //入栈

print_r($stack);

?>

$stack = array("Simon", "Elaine"); //Define array

array_push($stack, "Helen", "Peter"); //Push to the stack

print_r($stack);

1

2

3

4

5

$stack = array("Simon", "Elaine", "Helen", "Peter");

echo array_pop($stack)."/n"; //出栈

print_r($stack);

?>

?>

1

2

3

4

5

$stack = array("Simon", "Elaine", "Helen", "Peter");

echo array_shift($stack)."/n"; //出栈

print_r($stack);

?>

1 2

34 5
$stack = array("Simon", "Elaine"); //Define array array_unshift ($stack, "Helen", "Peter"); //Push onto the stack print_r($stack);

?>
1 2 3 4 5 <🎜>$stack = array("Simon", "Elaine", "Helen", "Peter");<🎜> <🎜>echo array_pop($stack)."/n"; //Pop from the stack<🎜> <🎜>print_r($stack);<🎜> <🎜>?>
1 2 3 4 5 <🎜>$stack = array("Simon", "Elaine", "Helen", "Peter");<🎜> <🎜>echo array_shift($stack)."/n"; //Pop the stack<🎜> <🎜>print_r($stack);<🎜> <🎜>?>
http://www.bkjia.com/PHPjc/1015879.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1015879.htmlTechArticleExample analysis of pushing and popping php linear tables into the stack This article explains the pushing and popping of php linear tables usage. Share it with everyone for your reference. The details are as follows: 1 2 3 4 5 ?php $stack = arra...
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