Re: Splitting a string

From: Date: Thu, 16 Nov 2006 00:17:15 +0000
Subject: Re: Splitting a string
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-244703@lists.php.net to get a copy of this message
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 )
?>
I knew there was another way ;) Thanks for the reminder.. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#244703) next »