0, 'data' => array()); } function que_ingress(&$que, $val) { array_push($que['data'], $val); ++$que['size']; } function que_egress(&$que) { --$que['size']; return array_shift($que['data']); } function que_depleted(&$que) { if($que['size']==0) { return true; } else { return false; } } function que_drop(&$que) { --$que['size']; array_shift($que['data']); } echo "\n\nThe non OO approach\n"; $que = &new_que(); $val=''; $list=array('Stewart', 'Schwantz', 'Falapa', 'Rossi', 'Earnhardt', 'Crevier'); # Enter data into the que while(list($k, $v)=each($list)) { que_ingress($que, $v); } # Drop the car driver que_drop($que); while(que_depleted($que)==false) { $val=que_egress($que); if($val=='Earnhardt') { /* Get rid of the other car driver */ } else { echo $val."\n"; } } Unset($que, $list); echo "\n\nNow for the OO approach\n"; # The OO approach class Que { var $q=array(); var $cntr; function ingress($val) { $this->q[]=$val; ++$this->cntr; } function egress() { if($this->cntr>0) { --$this->cntr; return array_shift($this->q); } else { return false; } } function drop() { if($this->cntr>0) { array_shift($this->q); --$this->cntr; } else { return false; } } function depleted() { if($this->cntr==0) { return true; } else { return false; } } } $que = &new Que; $list=array('Cey', 'Jordan', 'Sprewell', 'Plunkett', 'Iverson', 'Duncan'); # Enter data into the que while(list($k, $v)=each($list)) { $que->ingress($v); } $que->drop();// Get rid of the baseball player while($que->depleted()==false) { $val=$que->egress(); if($val=='Plunkett') { /* Who likes football anyways? */ } else { echo $val."\n"; } } ?>