Jump to content

[SOLVED] PHP Array for Form Elements


Omzy

Recommended Posts

I'm creating a form and want some drop down boxes generated from an array: I want to do something like this:

 

 
$attributes=array(
'location'=>array('manchester'=>'Manchester', 'london'=>'London'),
);

 

Essentially what I want the code to do is output the following:

 

 
<select name="location">
<option value="manchester">Manchester</option>
<option value="london">London</option>
</select>

 

I've got the code to match on the outer array but I now need a foreach loop which will output the values from the inner array. I want to do this using one main array ($attributes) only.

Link to comment
https://forums.phpfreaks.com/topic/151634-solved-php-array-for-form-elements/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.