标签:off stack php function ret HERE nod node int
$arr1 = array();
$arr2 = array();
function push($node){
global $arr1;
array_push($arr1,$node);
}
function pop(){
global $arr1;
global $arr2;
if (!empty($arr2)){
return array_pop($arr2);
}else{
while (!empty($arr1)){
array_push($arr2,array_pop($arr1));
}
return array_pop($arr2);
}
}
push(1);
push(2);
push(3);
print_r($arr1);
print_r(pop());
$stack = array();
function mypush($node)
{
// write code here
global $stack;
return $stack[]=$node;
}
function mypop()
{
global $stack;
if($stack){
return array_shift($stack);
}
return $stack;
}
标签:off stack php function ret HERE nod node int
原文地址:https://www.cnblogs.com/cyworz/p/11230804.html