note 22362 deleted from language.types.integer by bjori

From: Date: Sat, 25 Mar 2006 21:43:15 +0000
Subject: note 22362 deleted from language.types.integer by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106609@lists.php.net to get a copy of this message
Note Submitter: kennyc at horizondigital dot com ---- 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!

« previous php.notes (#106609) next »