Getting 2 values in a Dropdownmenu


I have a problem I encountered today.

I want to have 2 certain values in my dropdownbox, one that decides the value and one value that decides the name, but there is a problem, the certain value is not in an array but rather it reas a directory:

[php]if ($handle = opendir(checkSlash($config[‘path_demos’])))
while (false !== ($file = readdir($handle)))
if ($file != “.” && $file != “…”)
if (strpos($file, “.exe”) !== FALSE)
$file = substr($file, 0,strrpos($file,’.’));
$demo_count[] = $file;


When that has happened I put it in a array:


$demo_count[0] => ‘Easyvoras’,
$demo_count[1] => ‘Easypos’);[/php]

After that I try to make the option:

[php]foreach($demo_count as $demo_option => $names_dropdown)

But the “$demo_option” always returns as a number not a name!

With kind regards,
Jelle van Lanen

[php]echo ‘’.$demo_option.’’;[/php]

in this line, you are trying to use $demo_option which is an array not a single value… so, it is trying to return true / false based on array existence. Instead, if you want to have the array items u should be using $demo_option[0] or $demo_option[1].

if you want both values to the option, well it may not be directly possible, coz each option holds one value only. there is an indirect way though.

[php]echo ‘’.implode(",", $demo_option).’’;[/php]

here, now all the items in the array are displayed as a string separated by commas. the total string submits to your processing page, there u can split the string by comma and use individual items as usual.

Sponsor our Newsletter | Privacy Policy | Terms of Service