Home >Backend Development >PHP Tutorial >Solution when the array element obtained by fgetcsv is an empty string

Solution when the array element obtained by fgetcsv is an empty string

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 09:05:201157browse
  1. // The uploaded CSV file is usually GBK encoded edited with Excel,

  2. // The source code is UTF-8 and needs to be transcoded
  3. file_put_contents( $new_file, iconv('GBK', 'UTF-8', file_get_contents($new_file)));

  4. //ini_set('auto_detect_line_endings', true);

  5. // Set area: Simplified Chinese, UTF-8 encoding
  6. setlocale(LC_ALL, 'zh_CN.UTF-8');
  7. // Open CSV file
  8. $handle = fopen($new_file, 'r');
  9. // Remove column headers
  10. $data_heads = fgetcsv($handle);
  11. ?>

Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn