Page 1 of 1

pass array values in a form

Posted: Fri Sep 02, 2005 5:30 pm
by dimitris83
Hello!
Well I have this problem, I have an array and I want to pass all the values of this array in a form object ( a drop down list for example). I can't find how can I do this, I can only pass the values one by one, but the problem is that I don't know how many values I will have.
Any suggestions? :?:

Posted: Fri Sep 02, 2005 5:40 pm
by John Cartwright

Code: Select all

$array = array('value1', 'value2', 'value3');

$html = '<select name="some_name">';
foreach ($array as $element) {
   $html .= '<option value="'.$element.'>'.$element.'</option>';
}
$html .= '</select>';
foreach()

Posted: Fri Sep 02, 2005 5:48 pm
by dimitris83
Thanks my friend!! You are great (and very quick :D )