Skip to content
Advertisement

PhP export .csv change delimiter from comma to others

I have this PhP code where in the user clicks a button and it automatically downloads a .csv file and inside it are different kinds of information. So this .csv file is comma delimited so it means whenever there is a comma the pointer goes to the next cell. But i’d like to change the delimiter to anything other than comma because some of my data has comma for example Location column has data such as 501A, 501B and it needs to be on a single cell. But instead it goes to another cell so id doesnt fit when I print it in portrait. So i just wanna ask how can I change the delimiter and maintain the data with commas? thanks!

JavaScript

Advertisement

Answer

You can use fputcsv() for generation data in csv format

JavaScript

EDIT:

Your code will be looks somethiing like this:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement