/    Sign up×
Community /Pin to ProfileBookmark

display result in a dropdown box

Hello all,

I have the code below that compares the values specified in $array_list with certain values stored in $email1 –> $email16. Only the results that aren’t contained in both $array_list and $array_1 are displayed in the “echo” command. Right now, the results are just displayed on one line with a comma between the results. What I would like to do is have all the results displayed in one dropdown box where each result is on a different line within the one dropdown box. And help would be greatly appreciated.

Thanks,
Cedric

<?
$array_list = array(‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’10’,’11’,’12’,’13’,’14’,’15’,’16’);
$array_1 = array($email1, $email2, $email3, $email4, $email5, $email6, $email7, $email8, $email9, $email10, $email11, $email12, $email13, $email14, $email15, $email16);
echo implode(‘,’, array_diff($array_list, $array_1));
?>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@MrBaseball34Oct 11.2010 — Try something like this:
<i>
</i>$array_list = array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
$array_1 = array($email1, $email2, $email3, $email4, $email5, $email6, $email7, $email8, $email9, $email10, $email11, $email12, $email13, $email14, $email15, $email16);
$arr = array_diff($array_list, $array_1);
echo "&lt;select&gt;";
foreach ($arr as $value) {
echo " &lt;option value="$value" /&gt;$value&lt;/option&gt;";
}
echo "&lt;/select&gt;";
×

Success!

Help @cedric813 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...