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

WBOY
Release: 2016-07-25 09:05:20
Original
1084 people have browsed it
  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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!