phpme1221 Posted July 20, 2011 Share Posted July 20, 2011 Can someone help with a form drop down from an array? The array is not known until you print_r mean could be 2 could be 10 values in the array. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/242451-dropdown-menu-from-an-array/ Share on other sites More sharing options...
premiso Posted July 20, 2011 Share Posted July 20, 2011 Use foreach $dd = '<select name="selectnamehere"> foreach ($array as $item) { $dd .= '<option value="' . $item . "'>'. $item . '</option>'; } $dd .= '</select>'; echo $dd; Should get you started. Quote Link to comment https://forums.phpfreaks.com/topic/242451-dropdown-menu-from-an-array/#findComment-1245245 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.