0
I would like to know how I can collect and store column data in a. csv file with PHP?
0
I would like to know how I can collect and store column data in a. csv file with PHP?
1
To write to a file I believe it is as follows
//você pode transformar os dados em uma array para cada coluna e linha
$dados = array(
//array('ID','Nome','Endereço','Telefone'),
array('1','Maria da Silva','Rua da Maria','(11)12345678'),
array('2','Pedro Cardoso','Rua do Pedro','(11)12345678'),
array('3','Joana Pereira','Rua da Joana','(11)12345678')
);
//aqui você grava os dados em um arquivo csv
$file = new SplFileObject('dados.csv','w');
$file->setCsvControl(',');
foreach($dados as $linha){
$file->fputcsv($linha);
}
and to get the data I searched in the php manual
$file = new SplFileObject("dados.csv",'r');
//enquanto nao for o fim do arquivo
while (!$file->eof()) {
var_dump($file->fgetcsv());
}
Browser other questions tagged php csv txt
You are not signed in. Login or sign up in order to post.
Import PHP CSV file
– rray