Generate options by using user defined function

<?php
  function generateOptions($start,$end,$inc){
    $options = '';
    for($i=$start; $i<=$end; $i+=$inc){
       $options = $options."<option>".$i."</option>";
    }
    return $options;   
  } 
?>

<select name="year">
  <option>Year</option>
  <?php
  echo generateOptions(1900,date('Y')-10,1);
  ?>
</select>



 

Comments

Popular posts from this blog

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine