PHP uses arrays as a stack, mostly using Array_push () and Array_pop () two system functions. The main use of the Array_push () function is to add one or more elements to the end of the first parameter's array, and then return the length of the new array, as shown in the following example:
In PHP, the array is considered as a queue and is mainly implemented with Array_push () and Array_shift ().
Copy CodeThe code is as follows:
$zhan =array ("WEB");//declaring an array as a queue
Array_push ($zhan, "PHP");//Press the string into the stack (array)
Array_push ($zhan, "WWW.CHHUA.COM");//press into an element again
Print_r ($zhan);//print array contents
?>
The stack is mainly using the Array_shift () function to eject the first element of the array and reduce the length of the array by 1, as shown in the following example:
Copy CodeThe code is as follows:
$zhan =array ("Web", "www.chhua.com", "Web Development note", "PHP", "website building");//Declare an array as a stack
Array_shift ($zhan);//String out of the queue (array)
Print_r ($zhan);//printing array contents Array ([0] = web[1] = www.chhua.com[2] + WEB Development Note [3] = PHP)
?>
http://www.bkjia.com/PHPjc/325036.html www.bkjia.com true http://www.bkjia.com/PHPjc/325036.html techarticle PHP uses arrays as a stack, mostly using Array_push () and Array_pop () two system functions. The main step is to use the Array_push () function to add one to the end of the array of the first parameter ...