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

  • Home
  • SEARCH
  • 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 472959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:08:20+00:00 2026-05-13T00:08:20+00:00

My associative array. $money = array(Nickels => $_POST[nickels], Dimes => $_POST[dimes], Quarters =>$_POST[quarters]); My

  • 0

My associative array.

$money = array("Nickels" => $_POST["nickels"], "Dimes" => $_POST["dimes"], "Quarters" =>$_POST["quarters"]);

My html form set up to handle Quarters,
Dimes and Nickels are not shown in this case for brevity.

<label><b>Quarters:</b></label>
<select name="quarters" >
<option value=".25">25c</option>
<option value=".50">50c</option>
<option value=".75">75c</option>
<option value="1">$1.00</option>
</select>

A user can only select either Quarters only, Dimes only, or Nickels only.
If a user selects Quarters with the option value of .25, this value will be sent to
the php script.

So I was just wondering for calculations based on the fact that the user can select
Quarters only with one value, Dimes only with one value, and Nickels only with one
value, and not a combination of denominations,

how would one go about setting up different test cases, for example if the user selects
$money["Quarters"]; // With different values coming from the html form as .25, .50,.75, or 1, and only one of the selected values will make it through to the php script depending on what the user selected.

Can I do this:

switch($selection)
{
        case “Quarters”:
            echo “ You chose  $money[‘Quarters’];   .<br />”;
            break;
        case “Nickels”:
            echo “You chose $money[‘Nickels’]; .<br />”;
                break;
        case “Dimes”:
            echo “You chose  $money[‘Dimes’]; . <br />”;
                    break;
default: print  “Please select a Denomination”;
}

Thank you for not flaming the newb, I am still learning, and sorry for the mix and match in terms of " and “.

  • 1 1 Answer
  • 1 View
  • 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-05-13T00:08:20+00:00Added an answer on May 13, 2026 at 12:08 am

    Selected values in a form are submitted as $_POST['quarters'].

    I understand, that you want to check, if the user has selected more than one of your <select>s (correct?)

    So, I’d create a check like this:

    $selected = 0;
    
    if ($_POST['quarters'] != "DEFAULT_VALUE_OF_YOU_SELECT_QUARTERS")
    {
     $selected++;
    }
    
    if ($_POST['nickels'] != "DEFAULT_VALUE_OF_YOU_SELECT_NICKELS")
    {
     $selected++;
    }
    
    if ($_POST['dimes'] != "DEFAULT_VALUE_OF_YOU_SELECT_DIMES")
    {
     $selected++;
    }
    
    if ($selected > 1)
    {
     // The user has selected more than one
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an associative array in the form key => value where key is
Is there an easy way to iterate over an associative array of this structure
I am not sure if I am doing this correctly,pre-loading my array values for
I have an associative array (object) of the following construction var menu = new
I want to create an associative array: var aa = {} // Equivalent to
I've got a multidimensional associative array which includes an elements like $data[status] $data[response][url] $data[entry][0][text]
Is there a simple way to retrieve the length of an associative array (implemented
What is the best way to have an associative array with arbitrary value types
I'm looking for a fast way to turn an associative array in to a
What is the most straightforward way to create a hash table (or associative array...)

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.