Re: Splitting a string

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

 



On Thursday 16 November 2006 01:12, Robert Cummings wrote:
> On Thu, 2006-11-16 at 10:47 +1100, Chris wrote:
> > Børge Holen wrote:
> > > Oh this was good.
> > > I added a while loop to insert extra strings "0" in front of the number
> > > to add if the string is less than 5 chars short.
> >
> > sprintf is your friend here, no need to use a loop.
> >
> > sprintf('%05d', '1234');
>
> No need to use a sledgehammer when a screwdriver will suffice:
>
> <?php
>
>     echo str_pad( '1234', 5, '0', STR_PAD_LEFT )

Yes this is perfect. Thanks...
I repeat this step for about a few hundred values.
So this speedup is greatly appreciated.

>
> ?>
>
> Cheers,
> Rob.
> --
> .------------------------------------------------------------.
>
> | InterJinn Application Framework - http://www.interjinn.com |
> |
> :------------------------------------------------------------:
> :
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for       |
> | creating re-usable components quickly and easily.          |
>
> `------------------------------------------------------------'

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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