SPL

http://php.net/spl


<?php
$iterator = new GlobIterator('/var/log/*.log');
foreach($iterator as $file) {
  echo $file->getFilename();
  echo "<br>";
}
?>
Output
alternatives.log
cloud-init-output.log
cloud-init.log
dpkg.log
droplet-agent.update.log

<?php
$q = new SplStack();

$q[] = 1;
$q[] = 2;
$q[] = 3;

foreach ($q as $elem)  {
 echo $elem."<br>\n";
}
?>
Output
3
2
1

<?php
$heap = new SplMaxHeap();
$heap->insert(2);
$heap->insert(1);
$heap->insert(3);
foreach ($heap as $elem)  {
 echo $elem."<br>\n";
}
?>
Output
3
2
1

<?php
class PQ extends SplPriorityQueue { 
    private $pris = array('high'=>3,'medium'=>2,'low'=>1);
    public function compare($pri1, $pri2) { 
        if ($pri1==$pri2) return 0; 
        return ($this->pris[$pri1]<$this->pris[$pri2]) ? -1 : 1; 
    } 
} 

$PQ = new PQ(); 
$PQ->setExtractFlags(SplPriorityQueue::EXTR_BOTH); 

$PQ->insert('Run','medium'); 
$PQ->insert('Sleep', 'high'); 
$PQ->insert('Fix annoying bug','low'); 
$PQ->insert('Eat','high'); 

foreach($PQ as $task) {
  echo "{$task['data']} -- {$task['priority']}<br>\n";
}
?>
Output
Sleep -- high
Eat -- high
Run -- medium
Fix annoying bug -- low