Home php entry in the CSV file

entry in the CSV file

Author

Date

Category

How to write data from an array in a CSV file?


Answer 1, Authority 100%

Use special fputcsv

& lt;? php
$ List = Array (
   Array ('Aaa', 'BBB', 'CCC', 'DDDD'),
   Array ('123', '456', '789'),
   Array ('"AAA"', '"BBB"')
);
$ fp = fopen ('file.csv', 'w');
Foreach ($ List AS $ Fields) {
   FPUTCSV ($ FP, $ Fields);
}
FClose ($ FP);

Answer 2

$ array = array ();
$ Hand = Fopen ("file.csv", "w");
For ($ i = 0; $ i & lt; = count ($ array); $ i ++)
{
FWRITE ($ Hand, $ Array [$ i]);
}
FClose ($ Hand);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions