Exemplo n.º 1
0
 /**
  *      Return HTML combo list of month
  *
  *      @param  string      $selected          Preselected value
  *      @param  string      $htmlname          Name of HTML select object
  *      @param  int         $useempty          Show empty in list
  *      @param  int         $longlabel         Show long label
  *      @return string
  */
 function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0)
 {
     global $langs;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
     if ($longlabel) {
         $montharray = monthArray($langs, 0);
     } else {
         $montharray = monthArray($langs, 1);
     }
     $select_month = '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">';
     if ($useempty) {
         $select_month .= '<option value="0">&nbsp;</option>';
     }
     foreach ($montharray as $key => $val) {
         if ($selected == $key) {
             $select_month .= '<option value="' . $key . '" selected>';
         } else {
             $select_month .= '<option value="' . $key . '">';
         }
         $select_month .= $val;
     }
     $select_month .= '</select>';
     return $select_month;
 }
Exemplo n.º 2
0
<?php

$num = rand(0, 100);
echo "your new random value is {$num} \n";
date_default_timezone_set("America/Los_Angeles");
function monthArray()
{
    $months = array();
    for ($i = 1; $i < 13; $i++) {
        $newMonth = $months[$i] = date('F', mktime(0, 0, 0, $i, 1, date('Y')));
        echo $newMonth;
    }
    echo "\n";
    sort($months);
    foreach ($months as $m) {
        echo $m;
    }
}
monthArray();