note 30065 deleted from function.number-format by tomsommer

From: Date: Mon, 28 Jun 2004 15:17:45 +0000
Subject: note 30065 deleted from function.number-format by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72048@lists.php.net to get a copy of this message
Note Submitter: gal_chen@hotmail.com ---- a better way to add a leadin zero $i = 15; while (strlen($i) < 3) $i = 0 . $i; can put it in a function or use a recoursive function function inc_length ($num,$length) { // $num is the number and $lenght is wanted length if (strlen($num) >= $length) { return $num; } else { return inc_length (0 . $num , $length); } } echo inc_length(23,5); will echo "00023"

« previous php.notes (#72048) next »