Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Use an Array as a Stack
How To Use an Array as a Stack? - PHP Script Tips - PHP Built-in Functions for Arrays
✍: FYIcenter.com
A stack is a simple data structure that manages data elements following the first-in-last-out rule. You use the following two functions together to use an array as a stack:
Here is a PHP script on how to use an array as a queue:
<?php
$waitingList = array();
array_push($waitingList, "Jeo");
array_push($waitingList, "Leo");
array_push($waitingList, "Kim");
$next = array_pop($waitingList);
array_push($waitingList, "Kia");
$next = array_pop($waitingList);
array_push($waitingList, "Sam");
print("Current waiting list:\n");
print_r($waitingList);
?>
This script will print:
Current waiting list:
Array
(
[0] => Jeo
[1] => Leo
[2] => Sam
)
2007-04-21, 5443👍, 0💬
Popular Posts:
If we have the following in a Java code: String s="abc"; String s2="abc"; Then what will be output o...
How can I check for HTML errors? HTML validators check HTML documents against a formal definition of...
How To Define a Data Source Name (DSN) in ODBC Manager? - Oracle DBA FAQ - ODBC Drivers, DSN Configu...
If client side validation is enabled in your Web page, does that mean server side code is not run? W...
How To Enter Microseconds in SQL Statements? - MySQL FAQs - Introduction to SQL Date and Time Handli...