note 46466 deleted from function.substr by sean
| From: | sean@php.net | Date: | Tue, 12 Oct 2004 15:38:09 +0000 |
| Subject: | note 46466 deleted from function.substr by sean | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78430@lists.php.net to get a copy of this message | ||
Note Submitter: cristian81 at katamail dot com
----
/*
Converts a number ($num) to a string with [$digits] number of chars.
Ex.: num2str(457, 5)
Returns the string: 00457
*/
function num2str($num, $digits) {
if ($num>0 && $digits>0) {
if (strlen(strval($num))>=$digits)
return $num;
else {
$string = "00000000000000000000000000000000000000000000000000".$num;
$digits_neg = 0-$digits;
return substr($string, $digits_neg, $digits);
}
}
else
return null;
}
----
Reason: useless example