From CSV to JSON using PHP | Wizworks
Summary
From CSV to JSON using PHP Had an application where I had to convert a ton of CSV logs to JSON format for ingestion by another system. I didn’t have good luck with Python, so I tried PHP. Keep in mind, this is a basic example and the following warning applies should this be considered for production use: Stern Warning: This example assumes the source of the CSV files is doing any error handling before writing records in the CSV source files. It is also assumed that the source CSV files each have a KEY as the first row in each file so that fields in the data rows are properly represented. Only use the example as shown if you are confident that your application/process creating the CSV source input files is doing proper data validation and handling!