|
Posted by kstampo on 12/08/07 09:24
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,ksta@gmail.com,4546464,"Saint Christopher",1,LAG,
57200,Greece
maria,papaso,mariapapa@yahoo.gr,4521028092,democracy,73,ΧΑΝΙΑ,
54254,Greece
Proto,Nik,proto@rtuom.gr,452310456456,hall,5,thessaloniki,45454,India
and if we suppose that I want to erase line 2, it should end up to:
kostas,stakos,ksta@gmail.com,4546464,"Saint Christopher",1,LAG,
57200,Greece
Proto,Nik,proto@rtuom.gr,452310456456,hall,5,thessaloniki,45454,India
Instead of this, I'm ending up with this:
kostas,stakos,ksta@gmail.com,4546464,"Saint Christopher",1,LAG,
57200,Greece
"
Proto,Nik,proto@rtuom.gr,452310456456,hall,5,thessaloniki,45454,India
"
Any ideas about this?????
[Back to original message]
|