nh_phpcoder Posted April 29, 2010 Share Posted April 29, 2010 hello, i need to create a select "combo box" in html with php that contains the following format as an example: select:0_None:Al_Al-Aluminum:S_S-Steel:W_W-Wood:O_O-Other the combo box to be created: <select name"myselect"> <option value="Al">Al-Aluminum></option> <option value="Al">S-S-Steel></option> <option value="W">W-Wood></option> <option value="O">O-Other></option> </select> thanks for any help Link to comment https://forums.phpfreaks.com/topic/200124-combobox/ Share on other sites More sharing options...
cags Posted April 29, 2010 Share Posted April 29, 2010 You could use something like this... $input = 'select:0_None:Al_Al-Aluminum:S_S-Steel:W_W-Wood:O_O-Other'; $parts = explode(':', $input); if($parts[0] == 'select') { echo '<select name="myselect">'."\r\n"; for($i = 1; $i < sizeof($parts); $i++) { echo '<option value="'.strtok($parts[$i], '_').'">'.strtok('_').'</option>'."\r\n"; } echo '</select>'; } Link to comment https://forums.phpfreaks.com/topic/200124-combobox/#findComment-1050483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.