fork(1) download
  1. <?php
  2. $array = [
  3. ['nome' => 'Luis', 'id' => 1],
  4. ['nome' => 'Rui', 'id' => 2],
  5. ['nome' => 'Joao', 'id' => 3],
  6. ['nome' => 'Joaquim', 'id' => 4],
  7. ['nome' => 'Jorge', 'id' => 5],
  8. ];
  9.  
  10. $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
  11.  
  12. $nomes = [];
  13.  
  14. foreach ($iterator as $key => $value)
  15. if ($key == 'nome') $nomes[] = $value;
  16.  
  17.  
  18. var_dump($nomes);
  19.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
array(5) {
  [0]=>
  string(4) "Luis"
  [1]=>
  string(3) "Rui"
  [2]=>
  string(4) "Joao"
  [3]=>
  string(7) "Joaquim"
  [4]=>
  string(5) "Jorge"
}