如果你有一个关联数组:
Array
(
[uid] => Marvelous
[status] => 1
[set_later] => Array
(
[0] => 1
[1] => 0
)
[op] => Submit
[submit] => Submit
)
你想访问第二个项目,你会怎么做?$arr[1]
似乎没有工作:
foreach ($form_state['values']['set_later'] as $fieldKey => $setLater) {
if (! $setLater) {
$valueForAll = $form_state['values'][$fieldKey];
$_SESSION[SET_NOW_KEY][array_search($valueForAll, $form_state['values'])] = $valueForAll; // this isn't getting the value properly
}
}
此代码应该产生:
$_SESSION[SET_NOW_KEY]['status'] = 1
但它只会产生一个空白条目。