Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8137751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:15:36+00:00 2026-06-06T11:15:36+00:00

I have a standard form array in PHP like this. I need to account

  • 0

I have a standard form array in PHP like this. I need to account for up to 10 hours of labor in 15 minute increments with 10 as a value for every 15 min or 40 per hour. Is it possible to automate this into some sort of array with PHP instead of hardcoding each of these values? It just seems like there should be a better way and I have no idea how to start?

<select size="1" name="labor" id="labor">
    <option value="80">2 Hours</option>
    <option value="70">1 Hour 45 min.</option>
    <option value="60">1 Hour 30 min.</option>
    <option value="50">1 Hour 15 min.</option>
    <option value="40">1 Hour</option>
    <option value="30">45 Minutes</option>
    <option value="20">30 Minutes</option>
    <option value="10">15 Minutes</option>
</select>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:15:37+00:00Added an answer on June 6, 2026 at 11:15 am

    Probably easiest to hardcode the solution. I think this is one of those situations where it is OK as @Wrikken mentioned, as it makes the code very clean and easy to maintain (Imagine coming back to this in a year or two). In addition this situation can also be handled very well with a database table.

    First use an array to store you values and descriptions:

    $list = array();
    $list['10'] = '15 Minutes';
    ....
    

    Then loop through the entire array to generate your dropdown:

    <select size="1" name="labor" id="labor">
    <?php
       foreach($list as $value => $desc){
         $option = "<option value=$value>" . $desc . "</option>";
         echo $option;
       }
    ?>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that have standard form authentication declared, like this: <login-config>
I have sales statistic data in array form to calc standard deviation or average
I have a series of standard OpenGL instructions in this form: glBegin(GL_TRIANGLES); // ...
I have a standard form in mvc4 operation. I use jQuery.post to perform postback
I have a custom TextBox on a standard Windows Form. In OnLeave() of the
I have the standard 'RequiredIf' attribute for some Conditional-Validation. My form and Model are
I have a form with most of its functionality implemented using standard TAction. I
We currently have a form with the standard multi-select functionality of here are the
I have a form I need to use on multiple pages: Controller $emailForm =
I have been tearing my hair out over this for about 3 hours, please

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.