Kwarcek

getBranches

Aug 23rd, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. /* Function getBranches */
  2.  
  3. function getBranches($branches_nr) {
  4.  
  5. $csv = array_map('str_getcsv', file('branches.csv'));
  6.  
  7. $key = array_search($branches_nr, array_column($csv, '0'));
  8.  
  9. return $csv[$key][1];
  10.  
  11. }
  12.  
  13. /* Usage example */
  14. $branches = getBranches('01');
  15.  
  16. /* Example return */
  17. CENTRALA BIERUŃ
  18.  
  19.  
  20. /* Branches CSV Example */
  21. "01","CENTRALA BIERUŃ"
  22. "15","BIAŁYSTOK"
  23. "12","BIELSKO-BIAŁA"
  24. "17","BYDGOSZCZ"
Advertisement
Add Comment
Please, Sign In to add comment