fork(1) download
  1. <?php
  2.  
  3. $bancos = array(
  4. array('code' => '001', 'name' => 'Banco do Brasil'),
  5. array('code' => '003', 'name' => 'Banco da Amazônia'),
  6. array('code' => '004', 'name' => 'Banco do Nordeste'),
  7. array('code' => '021', 'name' => 'Banestes'),
  8. array('code' => '025', 'name' => 'Banco Alfa'),
  9. array('code' => '027', 'name' => 'Besc'),
  10. array('code' => '029', 'name' => 'Banerj'),
  11. array('code' => '031', 'name' => 'Banco Beg'),
  12. array('code' => '033', 'name' => 'Banco Santander Banespa')
  13. );
  14.  
  15. echo BancoPorID( '001' ) . PHP_EOL;
  16. echo BancoPorID( '033' ) . PHP_EOL;
  17. echo BancoPorID( '027' ) . PHP_EOL;
  18.  
  19. function BancoPorID($id) {
  20. global $bancos;
  21. $key = array_search( $id, array_column( $bancos, 'code') );
  22. return $key !== false ? $bancos[$key]['name'] : 'Banco desconhecido';
  23. }
  24.  
  25.  
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Banco do Brasil
Banco Santander Banespa
Besc