foreach Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am new to PHP (4.3.9) and have been working on an open source application
helping someone.  At the same time I am learning PHP and honing my skills.
I've looked in the docs that came with PHP and tried to follow the example
but it was not well documented.

I have the following function.  The foreach seems to loop the correct number
of times BUT I get the following results.

single, married, divorced, widowed, single

instead of

single, married, divorced, widowed, separated


I have similiar problems with very similiar code.


Where have I gone wrong?  Any help is appreciated as well as a little
education of why I went wrong and why the right way.

Thanks.

Mike



function set_maritalstatus_select($block, $selected = '') {
global $t;

$array_maritalstatus = array("S" => "Single", "M" => "Married", "D" =>
"Divorced", "W" => "Widowed", "P" => "Separated");

$t->set_block($block, 'MaritalStatusSelectOption',
'MaritalStatusSelections');

foreach($array_maritalstatus as $Key=>$maritalstatus)
  {
   $t->set_var('MaritalStatusID', $maritalstatus[$Key]);
   select_var('MaritalStatusSelected', in_array($maritalstatus[$Key],
$selected));
   $t->set_var('MaritalStatusName',
$array_maritalstatus[$maritalstatus[$key]]);
   $t->parse('MaritalStatusSelections', 'MaritalStatusSelectOption', true);
  }
}

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux