<?php foreach (range(1, 12) as $month): ?>
<option value="<?= sprintf("%02d", $month) ?>"><?= sprintf("%02d", $month) ?></option>
<?php endforeach?>
You’d probably want to save the value of sprintf
to a variable to avoid calling it multiple times.
More Related Contents:
- Show a number to two decimal places
- PHP How do I round down to two decimal places? [duplicate]
- PHP number format
- How to display Currency in Indian Numbering Format in PHP?
- How to prefix a positive number with plus sign in PHP
- when upload zip folder validate that only .jpg,.png files will save inside zip folder +php [closed]
- Search engine PHP return error [closed]
- how to read Json values [closed]
- How to make a calculator in PHP?
- Convert backslash-delimited string into an associative array
- Setting the PHP default encoding to UTF-8
- How to setup ElasticSearch index structure with multiple entity bindings
- Remove all elements from array that do not start with a certain string
- scandir() to sort by date modified
- Print the keys of an array
- How to resolve “must be an instance of string, string given” prior to PHP 7?
- Get characters after last / in url
- Get Updated Value in MySQL instead of affected rows
- Pass data from jQuery to PHP for an ajax post
- Using MX records to validate email addresses
- What’s difference between __construct and function with same name as class has? [duplicate]
- Explode string by one or more spaces or tabs
- How to Make Laravel Eloquent “IN” Query?
- Laravel Eloquent ORM Transactions
- Optimizing Kohana-based Websites for Speed and Scalability
- Parse math operations with PHP
- How can I put my WAMP online for someone to access?
- Handling multiple file uploads in Sonata Admin Bundle
- PHP pass function name as param then call the function?
- Which MySQL datatype to use for an IP address? [duplicate]