Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this code is for output
- $selectedMonths = isset(io::$post['month']) && !empty(io::$post['month'])?io::$post['month']:date('m');
- io::$out['month'] = $this->getMonths(date('m'), $selectedMonth);
- //this is the function that gives me list of months, default item is a current month
- private function getMonths($selectedMonth) {
- $arr = array();
- $j = 0;
- for ($i = 1; $i <= 12; $i++) {
- if ($i < 10) {
- $i = "0" . $i;
- }
- $arr[$j]['number'] = $i;
- $monthName = date("F", strtotime(date("Y-$i-01")));
- $arr[$j]['name'] = $monthName;
- if ($i == $selectedMonth) {
- $arr[$i-1]['selected'] = "selected";
- } else {
- $arr[$i-1]['selected'] = "";
- }
- $j++;
- }
- return $arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement