Make 4 digit integer from one, two, or three digits integer in PHP

Viewed 27131

I'am doing a call to a database to retrieve an ID of a specific item. Usually there are the ids like: 1, 2, 14, 23, .... I need to get the ID from a DB and output it 4 digit number.

For exemple: My result ID is: 1. Now i when i have this value, i want it to become 0001. Or if my result id is 13, it should became 0013, etc.

How can i achieve that with php without changing the real ID in database?

4 Answers
Related