Re: counting with leading zeros
| From: | brian | Date: | Fri, 28 Sep 2007 00:30:13 +0000 |
| Subject: | Re: counting with leading zeros | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262546@lists.php.net to get a copy of this message | ||
tedd wrote:
At 3:58 PM -0400 9/26/07, brian wrote:I wasn't bitching! And i *thought* that my numerous attempts at explaining such would have been enough. Obviously not, but wtf can you do with people who seem to want only to stir up shit? Jim Lucas wrote:Well, this is almost precisely the same thing i have, save for using POSIX character classes, str_pad instead of sprintf(), and incrementing elsewhere. What i was really wondering is if there was a *much simpler* way to do this, not just re-arranging things.Rob just gave you code that works better than what you did and you're bitching about it? Look, none of us are on your payroll so appreciate what you're given. My advice, says thanks and if the code doesn't meet your expectations then learn how to better phrase your question next time. tedd
Well, I didn't want to get into the middle of this cat fight, but now that the talks have completely gotten off topic. I will interject...Perfect timing, then.
Here is a function that is a bit simpler then either of yours. Now, if you plan to delete any images in the list, this will not work.There's a daemon that locks the dir, zips up the contents, moves it elsewhere, then removes everything at once.
<?php function getNextImage($path, $prefix) { $filelist = glob("${path}${prefix}*") or return '01'; return str_pad(((int)count($filelist)+1), 2, '0', STR_PAD_LEFT); } ?>Sweet! Thanks much! brian