...

View Full Version : One of two arrays as parameter for function



dapierow
04-15-2012, 12:02 PM
Hello all, I am trying to create a function which am going to call multiple times, one of the parameters will be one of two arrays. It is suppossed to return the value of each array index into a proccessing form, while the key is supposed to go into the drop down list

the arrays are


$colors = array('White' =>'white','Black'=> 'black', 'Red'=>'red','Green'=>'green','Blue'=>'blue','Yellow'=>'yellow','Orange'=>'orange');
$fancy_colors = array('cyan' => '33CCFF', 'gold' => 'F5B800', 'pink' => 'FF33CC', 'lime' => 'CCFF33');

My calls for the function are:

selectBox($colors, "Text Color:", "textColor");
selectBox( $colors, "Background Color:", "backColor");
selectBox( $fancy_colors, "Box Color:", "boxColor");

My function:


function selectBox( $list, $title, $name)
{
echo "<p>""$title""<select name=""$name"">";
foreach ($list as $key => $value)
echo "<option value=" . "$value" . ">" . "$key" ." </option>";
echo "</select></p>";
return $value;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum