Connecting Tech Pros Worldwide Forums | Help | Site Map

File Names Into Array

boarderstu@gmail.com
Guest
 
Posts: n/a
#1: Jul 17 '05


right so im in the midst of creating a gallery for a friend of mine, i
have most of it right, but when i get the file names from the directory
and into an array i have the ".." and "..." as the first two elements,
any ideas?

my getImages functions is simply as follows:

#PHP

function getImages()
{
global $images;
$mydir = opendir(images);


for($i=0; $i<10; $i++)
{
$entryname = readdir($mydir);
$images[] = $entryname;
echo("<br>");

}
#PHP


Geoff Berrow
Guest
 
Posts: n/a
#2: Jul 17 '05

re: File Names Into Array


I noticed that Message-ID:
<1108386773.836989.142200@l41g2000cwc.googlegroups .com> from
boarderstu@gmail.com contained the following:
[color=blue]
> for($i=0; $i<10; $i++)
> {
> $entryname = readdir($mydir);
> $images[] = $entryname;
> echo("<br>");[/color]


Well I don't think that's the only problem with this function. The only
thing it appears to output is line breaks.

This snippet from one of my scripts might help.

if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if(($file!="."&&$file!="..")){
echo "<tr><td>filename:&nbsp;</td><td><b> <a
href=\"$file\">$file</a></b></td><td>Type:&nbsp</td><td>". filetype($dir
.. $file)."</td><td align=\"center\"><input
type=\"checkbox\"name=\"delete[]\" value=\"$file\"><td></tr>\n";
}
}
closedir($dh);
}
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Closed Thread