fork download
  1. <?php
  2.  
  3. function &collector() {
  4. static $collection = array();
  5. return $collection;
  6. }
  7. $collection = &collector();
  8. $collection[] = 'foo1';
  9. $collection[] = 'foo2';
  10. $collection[] = 'foo3';
  11.  
  12. print_r($collection);
  13. print_r(collector());
Success #stdin #stdout 0.02s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => foo1
    [1] => foo2
    [2] => foo3
)
Array
(
    [0] => foo1
    [1] => foo2
    [2] => foo3
)