fork(3) download
  1. <?php
  2.  
  3.  
  4. $bigArray = array(
  5. 'name'=>'one',
  6. 'something'=>array(
  7. 'name'=>'two',
  8. 'subthing'=>array('name'=>'three')
  9. ),
  10. 'anotherthing'=>array('name'=>'one')
  11. );
  12.  
  13. $uniques = array();
  14. $indirect = array(&$uniques);
  15.  
  16. function singleOut($item, $key, $indirect) {
  17. $uniques=&$indirect[0];
  18. if ($key == 'name' && !in_array($item,$uniques,true) ) $uniques[] = $item;
  19.  
  20. }
  21.  
  22. array_walk_recursive($bigArray, 'singleOut', $indirect);
  23. print_r($uniques);
  24.  
  25. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => one
    [1] => two
    [2] => three
)