WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Queue class VS Native array
Categories : PHP, PHP Classes, Arrays Click here to Update Your Picture
Chao Xu
Date : May 15th 2007
Grade : Be the 1st to grade this Code Example
Viewed : 762
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Chao Xu
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

The queue class I fixed up in a few minute, there are a comparison between my class and the native way of implementing it.

My Queue class
<?php
class queue{
        var
$q;
        var
$p=0;
        function
enqueue($stuff=null){
               
$this->q[]=$stuff;
        }
        function
dequeue(){
               
$a = $this->q[$this->p];
                unset(
$this->q[$this->p++]);
                return
$a;
        }
}
?>



Usage Example
<?php
$queue
= new queue;

//add things to queue
$queue->enqueue('stuff');

//take things out
$queue->dequeue();
?>


It is much faster on taking things out than the native verion

<?php
$queue
= array();

//add something in the queue
$queue[] = 'stuff';

//take something out
array_shift($queue);
?>



XML To Array
Categories : PHP, PHP Classes, XML, Arrays
PHPDRAW, the php wannabe Photoshop ;-)
Categories : PHP, PHP Classes, GD image library, Arrays
Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
A class to put get and post variables in hidden form elements. Works on scalars, normal arrays, associative arrays.
Categories : Algorithms, Variables, Arrays, PHP, PHP Classes
Array Insertion
Categories : PHP, PHP Classes, Arrays
HTML_Graphs uses PHP to provide a consistent interface for creating HTML based charts. The user of the class sets up arrays that are passed to html_graph() which then takes care of all the messy HTML layout.
Categories : Graphics, Arrays, PHP, PHP Classes, Charts and Graphs
Tweak Array, insert/add elements to any position of your arrays - delete elements from your arrays - move elements within your arrays - replace elements from your arrays ... the array, 'dynamically' grows or shrinks to whatever we tweak it.
Categories : PHP Classes, Arrays, PHP
Sort the results from a SELECT query (any number of columns) into an array automatically.
Categories : PHP, PHP Classes, Arrays, Databases, MySQL
Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs
PHP Script to find url links in a page
Categories : PHP, URLs, Regexps, Arrays
PHP4 DirectoryIterator Class
Categories : PHP, PHP Classes, Filesystem, Directories
Class to build a select tag in html, useful to build select boxes from a data base
Categories : PHP, HTML and PHP, PHP Classes
Email Class
Categories : PHP, Mail, PHP Classes
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
[PHP5] NOTIMEOUT PACKAGE
Categories : PHP, PHP Classes, AJAX