Jump to content

Dropdown Concatenation?


eekscarykat

Recommended Posts

I am currently learning Zend/PHP on the fly. I've gone from 0 to 40 in about 2 months, as far as savviness is concerned. I am working on a form that I want to display array information of two things (shortname and fullname) in a drop-down list. I am thinking I need to do some sort of concatenation to achieve this, or would I do an array within an array? The array is defined in a value object and that draws the id, shortname and fullname. Shortname is the defined label in that file. In the form page, i have the LO ['full_name'] => LO ['label']... this inputs the right information into the database, but shows the full name. I want the drop-down to show it as following: Shortname|Fullname. This will be used in a couple of places once I get on the right track on how to accomplish this. I would be accepting of any help, as well as any resourced that could answer my question and help me finish this form.

:confused:

 

Cheers,

ESK

Link to comment
Share on other sites

Not sure if this is even close to what you're looking for.

<?php
$names=array(
"id" => array(22,47,35),
"label" => array("Sally","Jim","John"),
"full_name" => array("Sally Field","Jim Beam","John Doe")
);
echo '<select name="names">';
foreach($names['id'] as $key => $id){
echo "<option value=\"$id\">{$names['label'][$key]}|{$names['full_name'][$key]}</option>";
}
echo '</select>';
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.