Reply to Re: Un-zipping file problem

Your name:

Reply:


Posted by Benjamin Esham on 08/07/06 00:54

Brian wrote:

> Below is a bit of code that opens up and reads a zip file.
>
> I'm having trouble working out how to read in line by line. The file I am
> unzipping is a CSV file and I need to return each line so I can work on
> them
>
> $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
>
> print "$buf<br>\n"; // << what to return each line so i can work on it

I'm not really familiar with the zip functions, but if $buf is the contents
of your file, you can use

$lines = preg_split("/[\r\n]+/", $buf);

to populate $lines with the lines of your file.

If $buf is just a temporary buffer, you could do something like

$contents .= $buf;

during each iteration of the loop, and the use preg_split() with $contents
after the loop has completed.

HTH,
--
Benjamin D. Esham
bdesham@gmail.com | AIM: bdesham128 | Jabber: same as e-mail
"A witty saying proves nothing." — Voltaire

[Back to original 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

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