protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fraggles = (include __DIR__ . '/../../../examples/fraggles.php');
     $arrayIterator = new \ArrayIterator($fraggles);
     // Print the array
     $output->writeln("The array in natural order");
     foreach ($arrayIterator as $thisFraggle) {
         $output->writeln("  " . $thisFraggle);
     }
     // print the array sorted
     $output->writeln("The array in alphabetical order");
     $arrayIterator->asort();
     foreach ($arrayIterator as $thisFraggle) {
         $output->writeln("  " . $thisFraggle);
     }
     // print the array sorted
     $output->writeln("Emprorer First order");
     $arrayIterator->uasort([$this, 'emperorFirst']);
     foreach ($arrayIterator as $thisFraggle) {
         $output->writeln("  " . $thisFraggle);
     }
     $output->writeln("Done");
     return;
 }
Beispiel #2
0
 public function asort()
 {
     parent::asort();
     $this->refreshPositions();
 }
Beispiel #3
0
<?php

$a = array(1, 2, 3);
$o = new ArrayIterator($a);
var_dump($o->next());
var_dump($o->rewind());
var_dump($o->seek());
var_dump($o->asort());
var_dump($o->ksort());
var_dump($o->natsort());
var_dump($o->natcasesort());