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>
    for ($i = date('Y'); $i <= date('Y')+10; $i++) {
        echo '<option value="'.$i.'">'.$i.'</option>';
    } ?>

Leave A Reply

Your email address will not be published.