codehaven - php snippets - coding help
Generic filters
Exact matches only

Add a leading zero to numbers – Sprintf

18th February 2019

Php - Maths

php codehaven

Problem: I have some code that displays
1,2,3,4,5
but I need
01,02,03,04,05

Answer below: –
(the %02d shows 1 zero before, change this to %02d and it will be 001)

Output 01

Was this code snippet helpful?