Return to Snippet

Revision: 1317
at September 27, 2006 11:37 by gdonald


Updated Code
function getMonthOptions( $selected )
{
    $options = '';

    for( $x = 1; $x < 13; $x++ )
    {
        if( strlen( $x ) == 1 ) $x = '0' . $x;

        $options .= '<option value="' . $x . '"';

        if( $x == $selected )
        {
            $options .= ' selected="selected"';
        }

        $options .= '>' . $x . '</option>';
    }

    return $options;
}

Revision: 1316
at September 27, 2006 11:37 by gdonald


Initial Code
function getMonthOptions( $selected )
{
    $options = '';

    for( $x = 1; $x < 13; $x++ )
    {
        if( strlen( $x ) == 1 ) $x = '0' . $x;

        $options .= '<option value="' . $x . '"';

        if( $x == $selected )
        {
            $options .= ' selected="selected"';
        }

        $options .= '>' . $x . '</option>';
    }

    return $options;
}

Initial URL


Initial Description


Initial Title
PHP month options

Initial Tags


Initial Language
PHP