note 22362 added to language.types.integer
| From: | kennyc at horizondigital dot com | Date: | Fri, 14 Jun 2002 22:57:14 +0000 |
| Subject: | note 22362 added to language.types.integer | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31872@lists.php.net to get a copy of this message | ||
ONELINE LEADING ZERO ADDER: I kept getting frustrated by php's weak number formatting functions
and using the recursive leading zero adders that I've seen in other people code, so here's
my quick and easy oneliner for adding leading zero's to any number:
Two digit space:
substr($num+100,1);
0=00
5=05
23=23
3.14=03.14
Four digit space:
substr($num+10000,1);
0=0000
5=0005
23=0023
256=0256
4096=4096
98.6=0098.6
You may want to check first to be sure that your number dosen't already exceed it's
character size!
--
http://www.php.net/manual/en/language.types.integer.php
http://master.php.net/manage/user-notes.php?action=edit+22362
http://master.php.net/manage/user-notes.php?action=delete+22362
http://master.php.net/manage/user-notes.php?action=reject+22362