You are here: using fputcsv() « PHP Programming Language « IT news, forums, messages
using fputcsv()

Posted by shenoyvikram on 11/08/07 15:34

New to PHP

I am trying to search through a csv file. when I match a string I want
to replace it using the fputcsv function. However, I always notice
there is an extra line inserted. I am using fseek to move file
pointer.
- does fputcsv replace or insert data into csv file?
Code below and example of problem also.
while( ($data = fgetcsv($fid, 1000, ",")) !== FALSE) {
if (strcmp ($data[0], $compare) == 0){
fseek ($fid,$offset_counter);
fputcsv($fid, $data1);
$offset_counter = ftell ($fid);
}

My starting file
11,11,11,11
22,22,22,22
33,33,33,33

The output I expect
11,11,11,11
33,22,22,22
33,33,33,33

The output I am getting
11,11,11,11
33,22,22,22

33,33,33,33

 

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

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