Can someone show me how to do the following?
I have a variable named $day. If the value of $day is between 1 and 9 and it is represented by a single digit like “1”, I would like to set $day to 01.
How would I do this?
rouse
0
Junior Poster
Recommended Answers
Jump to Post<?php $day = "2"; $newday = printf("%02s", $day); echo $newday; ?>
Result is 02.
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.