Please reply to the list not just directly to me.
Alf Stockton wrote:
> Stut wrote:
>> ..snip..
>
>>// Really not sure why this is here
>>--$Count;
>>//echo 'Count = '.$Count.' $tempvar = '.$tempvar;
>>
> .snip.
> Part of the backwards iteration. In other word
Alf Stockton wrote:
Hendrik Visage wrote:
On 9/8/06, Alf Stockton <[EMAIL PROTECTED]> wrote:
In this little script:-
Obviously $names won't be defined in the initial state the first time
this line
is hit, thus count($names) would/should be undefined...
Interesting that this works on version
Hendrik Visage wrote:
> On 9/8/06, Alf Stockton <[EMAIL PROTECTED]> wrote:
>> In this little script:-
>>
>> > session_start();
>> //read folder
>> $folder=opendir(".");
>> while ($file = readdir($folder))
>> $names[count($names)] = $file; // <- Line 8
>
> Obviously $names won't be defined in t
Foreach is very much better as it does not mean having to traverse the
array to find the given value. If you have a long array, you'll find
looking up a element by index gets slow.
AJ
Stut wrote:
Hendrik Visage wrote:
right>
The rewrite below does not iterate around the array as you were i
Hendrik Visage wrote:
The rewrite below does not iterate around the array as you were in your
for loop, so I'll mention a better way to do that here rather than in
the snippet below... foreach - look it up in the PHP manual!
One way to rewrite it would be like this (with comments hopefully
On 9/8/06, Alf Stockton <[EMAIL PROTECTED]> wrote:
In this little script:-
Obviously $names won't be defined in the initial state the first time this line
is hit, thus count($names) would/should be undefined...
closedir($folder);
//sort file names in array
sort($names);
//remove any non-imag