eekscarykat Posted May 22, 2012 Share Posted May 22, 2012 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. Cheers, ESK Quote Link to comment https://forums.phpfreaks.com/topic/262924-dropdown-concatenation/ Share on other sites More sharing options...
Drummin Posted May 22, 2012 Share Posted May 22, 2012 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>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/262924-dropdown-concatenation/#findComment-1347645 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.