Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <?php
  2. function get_db_csv($file){
  3. if(!$file){
  4. $file = __DIR__.'/include/import.csv';
  5. }
  6. $row = 1;
  7. if (($handle = fopen($file, "r")) !== FALSE) {
  8. $csv = array();
  9. while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
  10. if($row==1){
  11. $column_name = $data;
  12. }else{
  13. foreach ($column_name as $key => $value) {
  14. $db_csv[$data[0]][$value] = $data[$key];
  15. }
  16. }
  17. $row ++;
  18. }
  19. fclose($handle);
  20. }
  21. }
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement