--- Pete <[EMAIL PROTECTED]> wrote:
> >> Does anyone have any suggestions as to find out how many pictures there
> >> are on the server, with the pattern 'pix/1234*' - and how I can go
> >> through the file names?
> >
> >this?
> >
> ><?php
> > $dh=opendir('pix/');
> > while ($f=readdir($dh))
> > if (preg_match("/^\d+_\d+.(jpg|jpeg|gif|png)$/i",$f)
> > echo "found image: $f\n";
> >
> > closedir($dh);
> >?>
>
> [EMAIL PROTECTED] preg_match - I should have known (:->
>
> Thanks for that.
>
> Would you / anyone have any idea of whether this will slow down if there
> are a lot of pictures - there could be up to 1000/1200 in each folder.
>
> --
> Pete Clark
It is often best to stay with the PHP functions if you want to maintain
compatability to install the same program on Windows or *nix machines.
However, if you know you are only going to use Unix/Linux/OSX then you can use
the commandline utilities to get the results you want.
It should be noted at this point that taking any sort of user input and
applying it to a Unix command can be very risky. You should validate any user
inputs and watch for special characters which might let someone execute
arbitrary commands.
Also, the PHP program will run commands as the web server user (apache or
nobody on many *nix machines).
That said, if you merely wanted a count you could do something like:
$cmd = "ls pix/1234* | wc -l";
$num = system($cmd);
You may need to give a full path for the files.
James
_____
James D. Keeline
http://www.Keeline.com http://www.Keeline.com/articles
http://Stratemeyer.org http://www.Keeline.com/TSCollection
http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Summer Semester Begins Jun 20 -- New Classes Start Every Few Weeks.
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12h1poduc/M=362329.6886308.7839368.1510227/D=groups/S=1705005703:TM/Y=YAHOO/EXP=1122997839/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~->
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/