----- Original Message ----- 
From: "Wade Smart"

Thanks Rob. That worked.

Question. From my original code you can see I scan the directory, post
how many files are in the directory and their names. Next I rename them.
All that is working. What I want to do now is run another scan on the
directory posting the "new" file names. Im just reusing the same code
from above. However, its not putting out any names.

Is there a problem of, because this is sequential that once the names
are changed php cant get another reading on the file names?

Wade
-----------------------------

Hello Wade,
                   A directory scan is a stream resource and as such it is 
buffered in ram. When you change names in the file system then those changes 
are immediate but may not be reflected in a directory scan that was opened 
before the changes.

PHP does not itself cache filenames so it is only necessary to do a 
clearstatcache for the sake of your own variables in php. The only exception 
to this rule is with is_uploaded_file group.

rename('fred', 'john'); rename('john', 'peter');

The above will work fine however a directory scan that was opened prior to 
the rename will still show 'fred' even though the file is now 'peter'.

I see you excluded the file (directory) names '.' and '..' There are other 
possibilities. There can also be subdirectories, symlinks and other stream 
resources. It is better to use -
if(is_file'($filename)){
to exclude everything but files.

Hope this helps, Rob.



Reply via email to