Re: counting with leading zeros

From: Date: Thu, 27 Sep 2007 13:21:30 +0000
Subject: Re: counting with leading zeros
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-262522@lists.php.net to get a copy of this message
On Wed, 2007-09-26 at 21:56 -0700, Jim Lucas wrote: > > Now, if you plan to delete any images in the list, this will not work. > > But if you don't expect to delete any images in the list and always want > the ($total_images + 1), then follow along. > > <?php > > function getNextImage($path, $prefix) { > $filelist = glob("${path}${prefix}*") or return '01'; > return str_pad(((int)count($filelist)+1), 2, '0', STR_PAD_LEFT); > } > > ?> Nice :) Cheers, Rob. -- ........................................................... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ...........................................................

« previous php.general (#262522) next »