$lines = array_map('str_getcsv', file($filePath));; 

$result = array();
$headers = null;

if (count($lines) > 0) {
    $headers = $lines[0];
}

for($i=1; $i<count($lines); $i++) {
    $obj = $lines[$i];
    $result[] = array_combine($headers, $obj);//转成数组
}

$json =  json_encode($result, JSON_PRETTY_PRINT);//转成JSON

  

相关文章:

  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2021-11-17
  • 2022-02-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案