Re: [PHP] Month with leading zeros

[email protected] (Casey)
Newsgroups php.general
Message-ID <[email protected]>
On 5/10/08, Ron Piggott <[email protected]> wrote:
> I am wanting to change
>
>          echo "<option value=\"" . $months[$month] . "\"";
>
>  to output the month number, between 01 and 12 --- DATE value m, the
>  month with leading 0's.  How do I do this?  $months is an array, as I
>  have shown below.  Ron
>
>  <?php
>  $months = array('1' => 'January', '2' => 'February', '3' => 'March', '4'
>  => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August',
>  '9' => 'September', '10' => 'October', '11' => 'November', '12' =>
>  'December');
>
>  $current_month = DATE("n");
>
>  echo "<SELECT NAME=\"order_received_month\">\r\n";
>
foreach ($months as $i => $month)
>      {
>          echo "<option value=\"" . $month . "\"";
>
>  if ( $i == $current_month ) { echo " SELECTED";}
>
>  echo">" . $month . "</option>\r\n";
>      }
>  ?>
>  </select>
>
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
-Casey
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.