Recent Topics

1 Jan 17, 2008 01:46    

I use this snippet of code to make an array of a folde with pictures. Lateron I use the array to do some magic random stuff choosing a few of the pics for display. This is the snippet:

$handle = opendir('../images/zijpanelen');
while (false !== ($file = readdir($handle)))
{
	$picArray[] = $file;

};
closedir($handle);


Now the funny part is, at times there is no picture chosen. The reason: it sees the parent folder as a file and so as a pic. The relative URL of the pic becomes

'../images/zijpanelen/..

For some website I took some code I wrote a while back (some years). I was pleasantly surprised by what I made in the dark ages. Some nifty work arounds in a programming language I barely knew. I needed to do a lot of cleening up though. And I wonder why I left the database connection info in a plain text file?

2 Jan 17, 2008 14:59

i'm not sure if you're asking a question, but the answer is :

if( !in_array( $file, array( '.', '..' ) ) ) $picArray[] = $file;

¥

3 Jan 17, 2008 15:16

¥åßßå wrote:

i'm not sure if you're asking a question
¥

No :>
It's a known issue, but a curiousity non the less. With the other script i had 70+ pics in the folder, so I might never have found out there´s a bug. I re-used the code with only 10 pics in another folder. Now I am losing one in six pictures. ;)


Form is loading...