title: Print out key values of array from form
body: <p>Currently I am running a php file in a form of my own html file. I want the print out at the end the key values in my arrays. The arrays are to hold the values of the drop down boxes and radio boxes. I want to know how to connect the values the user chooses inside the ending echo lines for <code>operating system</code>, <code>processor</code>, <code>memory</code> and so forth. </p>
  
  <p>I tried doing:</p>
  
  <pre><code>echo "&lt;strong&gt;Operating system:&lt;/strong&gt; .$OS. &lt;br&gt;\n";
  </code></pre>
  
  <p>I also tried starting doing a:</p>
  
  <pre><code>foreach($OS as $cost =&gt; name) 
  </code></pre>
  
  <p>but only know about printing inside the loop.
  So I am hoping to get help understanding how to do this.</p>
  
  <p>The form is what you see below.<br>
  <img src="https://i.stack.imgur.com/pCxsj.png" alt=""></p>
  
  <p>Below is my <code>html</code> code:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;title&gt;Computer Store&lt;/title&gt;
  
    &lt;!-- Bootstrap --&gt;
    &lt;link href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"&gt;
    &lt;style type='text/css'&gt;
      select {
        border: 1px solid #669;
        font: bold 14pt;
        color: #3399cc;
        border-radius: 5px;
      }
      .c1 {
        width: 150px;
        font-weight: bold;
        color: #036;
      }
      td {
        padding: 5px;
      }
      input[type=text] {
        border: 2px solid #036;
        border-radius: 2px;
      }
      .outerbox {
        border: 2px solid #036;
        border-radius: 5px;
        margin: 0;
        padding: 0;
        margin-bottom: 10px;
      }
      #ctr {
        margin-top: 10px;
      }
    &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body class='container'&gt;    
  
    &lt;h2&gt;Online Computer Order Form&lt;/h2&gt;
  
    &lt;form name="OrderForm" method="GET" action="assignment1.php"&gt;
      &lt;div class='row outerbox'&gt;
        &lt;h2&gt;Configure your system&lt;/h2&gt;
        &lt;table class='table'&gt;
          &lt;tr&gt;
            &lt;td class='c1'&gt;Operating System&lt;/td&gt;
            &lt;td&gt;
              &lt;select name="os" id="os"&gt;
                &lt;option value="0"&gt;--select operating system--&lt;/option&gt;
                &lt;option value="w7"&gt;Windows 7&lt;/option&gt;
                &lt;option value="w7p"&gt;Windows 7 Pro&lt;/option&gt;
                &lt;option value="w8"&gt;Windows 8.1&lt;/option&gt;
                &lt;option value="u12"&gt;Ubuntu 12.04&lt;/option&gt;
              &lt;/select&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td class='c1'&gt;Processor&lt;/td&gt;
            &lt;td&gt;
              &lt;select name="processor" id="processor"&gt;
                &lt;option selected="selected" value="0"&gt;Intel Core i3&lt;/option&gt;
                &lt;option value="200"&gt;Intel Core i5&lt;/option&gt;
                &lt;option value="350"&gt;Intel Core i7&lt;/option&gt;
  
              &lt;/select&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
            &lt;td class='c1'&gt;Memory&lt;/td&gt;
            &lt;td&gt;
              &lt;input type="radio" name="memory" id="memory1" value="2200"&gt;128 GB
              &lt;input type="radio" name="memory" id="memory2" value="1600"&gt;64 GB
              &lt;input type="radio" name="memory" id="memory3" value="500"&gt;32 GB
              &lt;input type="radio" name="memory" id="memory4" value="295"&gt;16 GB
              &lt;input type="radio" name="memory" id="memory5" value="0" checked="checked"&gt;8 GB
  
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td class='c1'&gt;Hard Drive&lt;/td&gt;
            &lt;td&gt;
              &lt;input type="radio" name="hd" id="hd1" value="0" checked&gt;320GB
              &lt;input type="radio" name="hd" id="hd2" value="100"&gt;500GB
              &lt;input type="radio" name="hd" id="hd3" value="200"&gt;1000GB
              &lt;input type="radio" name="hd" id="hd2" value="350"&gt;2000GB
            &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
            &lt;td class='c1'&gt;CD/DVD Driver&lt;/td&gt;
            &lt;td&gt;
              &lt;input type="radio" name="cdr" id="cdr1" value="0" checked class="d_drive"&gt;DVD-ROM Drive
              &lt;input type="radio" name="cdr" id="cdr2" value="50" class="d_drive"&gt;DVD+/-RW Drive
            &lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;
      &lt;/div&gt;
      &lt;div class='row outerbox'&gt;
        &lt;h2&gt;Contact Information&lt;/h2&gt;
        &lt;table class='table'&gt;
          &lt;tr&gt;
            &lt;td class='c1'&gt;First Name&lt;/td&gt;
            &lt;td&gt;
              &lt;input type="text" name="First" size="20" id='first' placeholder="First name"&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td class='c1'&gt;Last Name&lt;/td&gt;
            &lt;td&gt;
              &lt;input type="text" name="Last" size="20" id='last' placeholder="Last name"&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td class='c1'&gt;Phone #&lt;/td&gt;
            &lt;td&gt;
              &lt;input type="text" name="Phone" size="20" id='phone' placeholder="Phone"&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;
      &lt;/div&gt;
      &lt;h3&gt;Special instructions/Comments:&lt;/h3&gt;
      &lt;textarea name='comments' placeholder="If you have any comments or special instructions, please enter them here" class='form-control' rows='3'&gt;
      &lt;/textarea&gt;
      &lt;p id='ctr'&gt;
        &lt;input type="submit" value="Finalize sale" class='btn btn-primary'&gt;&amp;nbsp;
        &lt;input type="reset" value="Cancel" class='btn btn-danger'&gt;
      &lt;/p&gt;
    &lt;/form&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p><code>PHP</code> file:</p>
  
  <pre><code>&lt;?php
  
  // Begin by making variables for the user's First, Last Name and Phone number
  $first = $_GET['First'];
  $last = $_GET['Last'];
  $phone = $_GET['Phone'];
  //Array Variables for each section
  $OS = array('w7' =&gt; 'Windows 7', 'w7p' =&gt; 'Windows 7 Pro', 'w8' =&gt; 'Windows 8.1', 'u12' =&gt; 'Ubuntu 12.04');
  $Proc = array('0' =&gt; 'Intel Core i3', '200' =&gt; 'Intel Core i5', '350' =&gt; 'Intel Core i7');
  $Memory = array('2200' =&gt; '320 GB', '1600' =&gt; '64 GB', '500' =&gt; '32 GB', '295' =&gt; '16 GB', '0' =&gt; 
      '8 GB');
  $H_Drive = array('0' =&gt; '320 GB', '100' =&gt; '500 GB', '200' =&gt; '1000 GB', '350' =&gt; '2000 GB');
  $C_Drive = array('0' =&gt; 'DVD-ROM Drive', '50' =&gt; 'DVD+/-RW Drive');
  
  $Comments = $_GET['comments'];
  
  //Connecting options
  foreach ($OS as $cost =&gt; $name){
  
  
  }
  
  
  //Totaling Cost
  $total = 0;
  $salesTax = $total * .05;
  $purchaseTotal = $total + $salesTax;
  
  
  //Print out information
  
  echo "Thank you" .$first. " " .$last. " for using Sam's online store.  &lt;br&gt;\n";
  echo "You have selected the following system: &lt;br&gt;\n";
  
  echo "&lt;strong&gt;Base system&lt;/strong&gt;&lt;br&gt;\n";
  echo "&lt;strong&gt;Operating system:&lt;/strong&gt;&lt;br&gt;\n";
  echo "&lt;strong&gt;Processor:&lt;/strong&gt; &lt;br&gt;\n";
  echo "&lt;strong&gt;Memory:&lt;/strong&gt; &lt;br&gt;\n";
  echo "&lt;strong&gt;Hard drive:&lt;/strong&gt; &lt;br&gt;\n";
  echo "&lt;strong&gt;DVD Drive:&lt;/strong&gt; &lt;br&gt;\n";
  echo "&lt;strong&gt;Total:&lt;/strong&gt;"  .$total. "&lt;br&gt;\n";
  echo "&lt;strong&gt;Sales tax(5%):&lt;/strong&gt;"  .$salesTax. "&lt;br&gt;\n";
  echo "&lt;strong&gt;Total Amount:&lt;/strong&gt;"  .$purchaseTotal. "&lt;br&gt;\n";
  
  echo "&lt;strong&gt;Comments or special instructors:&lt;/strong&gt; &lt;br&gt;\n" .$Comments."&lt;br&gt;\n";
  
  ?&gt;
  </code></pre>