christa Posted April 8, 2012 Share Posted April 8, 2012 hi friends! this code foreach ( $users as $key => $value ) { $user_ids = implode(',', $value); echo "$key - $user_ids<br />"; } sends this output: user one - 376,373 user charlie - user beta - 372 I need the $user_ids are shown in a DropDownList, of course only if the $user_ids is not empty. How can I do? thanks! Link to comment https://forums.phpfreaks.com/topic/260551-foreach-and-dropdownlist/ Share on other sites More sharing options...
gizmola Posted April 8, 2012 Share Posted April 8, 2012 The html select tag makes a dropdown list. Display in list So you simply need to build the options in your foreach and echo out the data in the option tag. echo ''; foreach ( $users as $key => $value ) { $user_ids = implode(',', $value); if (!empty($user_ids)) { echo "$user_ids"; } } echo ''; Link to comment https://forums.phpfreaks.com/topic/260551-foreach-and-dropdownlist/#findComment-1335332 Share on other sites More sharing options...
christa Posted April 8, 2012 Author Share Posted April 8, 2012 ok thank you! Link to comment https://forums.phpfreaks.com/topic/260551-foreach-and-dropdownlist/#findComment-1335336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.