You are here: fputcsv problem.... « PHP Programming Language « IT news, forums, messages
fputcsv problem....

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?????

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация