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 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 awk that gets populated like this: chr_count[$3]++ When
I have a nested associative array like this: $inputTypes= array( natural => array( text,
I have an associative array assigned to a Smarty variable, something like this: $foo
Given an associative array (of the sort returned by jQuery.serializeArray() ) like this: [
I am not sure if I am doing this correctly,pre-loading my array values for
When declaring an associative array, how do you handle the indentation of the elements
I have an associative array with two object inside. Running this through $(myassoc).each() ,
Say you have an associative array of about 10,000 elements in size. Is this
I have an associative array, say: $a=array('x'=>3,'y'=>6,'z'=>12); and a value, say $c=9 From this,
I have an associative array in the form key => value where key is

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.