Re: Displaying Number values

From: Date: Mon, 04 Mar 2002 06:24:22 +0000
Subject: Re: Displaying Number values
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-87047@lists.php.net to get a copy of this message
Hi, You can achieve this by using the printf or sprintf statements. <? $numberval = 1; printf("My number = %02d", $numberval); ?> This will print "01" If numberval = 20 - it will only print "20". The %02d is the key. %02 means - print 2 characters with leading zero's if there aren't 2 characters. %03 - 3 characters with leading zero's etc etc Hope I've explained that ok. Sam Phillip S. Baker <phillip@freewolf.net> wrote in message news:5.1.0.14.0.20020303213806.00ab7a18@209.164.73.211... > Hey All, > > I want PHP to print out the value of a number in a variable as something > like 01. > However whenever I try to I only get 1. > > Is there a way around this? > > Phillip >

« previous php.general (#87047) next »