Reputation: 7768
I need to append a number of zeros to a integer value,That number of zeros may be upto 20.
echo sprintf("%020d",'123456789101112');
But i got the result
00000000002147483647
This is wrong,I need to get 00000123456789101112,Does anyone know what is the problem?
Upvotes: 2
Views: 152
Reputation: 8179
you can use str_pad:
$value = "123456789101112";
echo str_pad($value, 20, '0', STR_PAD_LEFT);
Output
00000123456789101112
Upvotes: 2