Re: counting with leading zeros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!
...........................................................

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux