note 72680 added to function.sprintf
| From: | php-general at lists dot php dot net | Date: | Mon, 29 Jan 2007 18:15:38 +0000 |
| Subject: | note 72680 added to function.sprintf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122325@lists.php.net to get a copy of this message | ||
In response to juan at ecogomera dot com:
I think what you want is:
$x = 3327
$y=decbin($x);
echo $y."<br>";
$z = sprintf("%012d", $x);
echo $z;
3327
110011111111
000000003327
Right? You were double-converting the number. First to binary, then again to decimal. You should be
converting the source number directly into the required base.
----
Server IP: 64.71.164.2
Probable Submitter: 63.125.44.226
----
Manual Page -- http://www.php.net/manual/en/function.sprintf.php
Edit -- https://master.php.net/note/edit/72680
Del: integrated -- https://master.php.net/note/delete/72680/integrated
Del: useless -- https://master.php.net/note/delete/72680/useless
Del: bad code -- https://master.php.net/note/delete/72680/bad+code
Del: spam -- https://master.php.net/note/delete/72680/spam
Del: non-english -- https://master.php.net/note/delete/72680/non-english
Del: in docs -- https://master.php.net/note/delete/72680/in+docs
Del: other reasons-- https://master.php.net/note/delete/72680
Reject -- https://master.php.net/note/reject/72680
Search -- https://master.php.net/manage/user-notes.php