By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

fputcsv problem....

P: n/a
Well, I face the following problem:

I read a csv file form disk as follows:
$fini= file($fileall); where $fileall is the filename...

Afterwards, I want to delete a 'record' and therefore I'm using the
following:
$fnew=fopen($fileall,"w");
$row=0;
foreach ($fini as $line)
{
$row++;
if ($row!=$rec)
{
fputcsv($fnew,split(',', $line));
}
}
fclose($fnew);

..where $rec is the line number that I want to delete from the
original file (it is passed through $_POST from am previous page...).

The original file is the following:
kostas,stakos,ks**@gmail.com,4546464,"Saint Christopher",1,LAG,
57200,Greece
maria,papaso,ma*******@yahoo.gr,4521028092,democra cy,73,ΧΑΝΙΑ,
54254,Greece
Proto,Nik,pr***@rtuom.gr,452310456456,hall,5,thess aloniki,45454,India

and if we suppose that I want to erase line 2, it should end up to:
kostas,stakos,ks**@gmail.com,4546464,"Saint Christopher",1,LAG,
57200,Greece
Proto,Nik,pr***@rtuom.gr,452310456456,hall,5,thess aloniki,45454,India

Instead of this, I'm ending up with this:
kostas,stakos,ks**@gmail.com,4546464,"Saint Christopher",1,LAG,
57200,Greece
"
Proto,Nik,pr***@rtuom.gr,452310456456,hall,5,thess aloniki,45454,India
"
Any ideas about this?????
Dec 8 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.