萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php線性表的入棧與出棧實例分析

php線性表的入棧與出棧實例分析

 本文實例講述了php線性表的入棧與出棧用法。分享給大家供大家參考。具體如下:

  1 2 3 4 5 <?php $stack = array("Simon", "Elaine"); //定義數組 array_push($stack, "Helen", "Peter"); //入棧 print_r($stack); ?>   1 2 3 4 5 <?php $stack = array("Simon", "Elaine"); //定義數組 array_unshift ($stack, "Helen", "Peter"); //入棧 print_r($stack); ?>   1 2 3 4 5 <?php $stack = array("Simon", "Elaine", "Helen", "Peter"); echo array_pop($stack)."/n"; //出棧 print_r($stack); ?>   1 2 3 4 5 <?php $stack = array("Simon", "Elaine", "Helen", "Peter"); echo array_shift($stack)."/n"; //出棧 print_r($stack); ?>
copyright © 萬盛學電腦網 all rights reserved