You are here: Re: fread, explode, and eof problem « PHP Programming Language « IT news, forums, messages
Re: fread, explode, and eof problem

Posted by Pedro Graca on 10/07/06 00:17

Joe wrote:
> and of course if their
> is a [...] different [...] way of doing this I'm all ears

I'd use file() instead of fopen(), fread(), feof(), fclose().
I'd use arrays (I *love* arrays).

<?php
$quotes = array();
$dir = opendir($lpath);
while ($f = readdir($dir)) {
if (preg_match('/\.txt$/', $f)) {
$quotes = array_merge($quotes, file($lpath . '/' . $f));
}
}
closedir($dir);

### Remove all blank entries from $quotes
$quotes = array_diff($quotes, array("\n"));

###
### ATTENTION
### The $quotes array may have "holes"
### If you need the keys in order without "holes" uncomment the next line
// $quotes = array_merge($quotes);
?>


--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

 

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

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