Create A Dynamic Credit Card Expiration Year Dropdown Using PHP

In the below code there is a dynamic credit card expiration year dropdown that will take the current year along with next 10 years. So we don’t need to update dropdown field every year.

<select name="expiry_year">
    <option value=''>Year</option>
    <?php 
    for ($i = date('Y'); $i <= date('Y')+10; $i++) {
        echo '<option value="'.$i.'">'.$i.'</option>';
    } ?>
</select> 

Leave A Reply

Your email address will not be published.