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 8232087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:42:50+00:00 2026-06-07T17:42:50+00:00

This is based in PHP. Is it possible to take an array like this:

  • 0

This is based in PHP.

Is it possible to take an array like this:

$SELECT_INDUSTRY = array("Medical" => "Specialty", "Dental" => "Specialty", "Pediatrics" => "Specialty");

And have that pass those two values into something simple like this:

<select>
    <option value="$SELECT_INDUSTRY[]">$SELECT_INDUSTRY[]</option>
</select>

Where Medical would be the value being passed, and Specialty would be the public facing text.

This is the function I’m using to build the actual select boxes:

$SELECT_INDUSTRY = array("Medical", "Dental", "Pediatrics");
$FORM_SELECT_SIZE = 'input-min';
function get_options_industry( $arr = array() ) {
global $FORM_SELECT_SIZE;
echo '<div class="control-group"><label class="control-label" for="industry">Industry</label><div class="controls"><select name="industry" id="industry" class="'.$FORM_SELECT_SIZE.'"><option value=>Select an Industry</option>';
foreach( $arr as $option ) {
    echo '<option>'.$option.'</option>';
}
echo '</select></div></div>';
}
$FORM_FIELD_INDUSTRY = $SELECT_INDUSTRY;

And this is how I’m displaying the select:

<?php get_options_industry( $FORM_FIELD_INDUSTRY ) ?>

I feel like I’m close, or at least on the right track, just can’t figure out how to pull the first array value into the value field, then the second into the actual name.

The goal is to get the value being passed in the form, is different than the public facing name. I realize that the above array definition I gave may not be the correct way to do this.

SOLUTION

Thanks to a couple responses below, here is the final answer to solve my problem:

$SELECT_INDUSTRY = array("Medical" => "Medical", "Dental" => "Medical", "Pediatrics" => "Medical");
$FORM_SELECT_SIZE = 'input-min';
function get_options_industry( $arr = array() ) {
global $FORM_SELECT_SIZE;
echo '<div class="control-group"><label class="control-label" for="industry">Industry</label><div class="controls"><select name="industry" id="industry" class="'.$FORM_SELECT_SIZE.'"><option value=>Select an Industry</option>';
foreach( $arr as $key => $value ) {
    echo '<option value="'.$value.'">'.$key.'</option>';
}
    echo '</select></div></div>';
}
$FORM_FIELD_INDUSTRY = $SELECT_INDUSTRY;

I then have to make sure that my key is unique so no duplicates are erased.

  • 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-07T17:42:51+00:00Added an answer on June 7, 2026 at 5:42 pm

    How about this?

    $SELECT_INDUSTRY = array("Medical" => "Specialty", "Dental" => "Specialty", "Pediatrics" => "Specialty");
    
    .... other stuff you already have ....
    
    foreach( $arr as $val => $option ) {
        echo '<option value="'.$val.'">'.$option.'</option>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a system (PHP based, but unimportant for this) that keeps
I have different php output in jQuery-based tabs. This output is formed from database
I have form like this: <form method=POST action=<?php echo base_url() ?>admin/admin_search> <fieldset> <label for=nalozi>Nalozi</label><input
I have a PHP-based web app that I'm trying to apply Apache's mod_rewrite to.
Is this possible? I return the time that something was posted via PHP function
I'm trying to develop a simple php based schedule ... This is my database
I'm folowing this tutorial to create php/jquery based chat application. In short, this code
I have this code: <div id=gll_select> <script> var caffe = $(#caffe).val(); $(#gll_select).load(<?php echo base_url()
Sorry for this based question. I am fresh to jqplot and would like to
I am currently trying to achieve something like this: Based on this class, I

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.