-9

我有可以通过代码显示的数组:

foreach($form->data as $key => $value){
echo 'Key is '.$key.' and Value is '.$value.'<br />';
}

我得到以下显示:

Key is language and Value is lv-LV
Key is Itemid and Value is 114
Key is option and Value is com_content
Key is pumpis_1 and Value is 1
Key is lietussargs and Value is 2

但我只需要显示[Itemid]在这种情况下是114 我该怎么做的值?谢谢!雷维斯

4

2 回答 2

5
echo $form->data['Itemid'];

或者,如果你的意思是在 foreach 循环内(因为你还有其他事情要做),那么使用这个:

foreach($form->data as $key => $value) {
    if( $key === 'Itemid' )
        echo $form->data['Itemid'];
}
于 2012-08-13T15:09:54.303 回答
1

您应该阅读PHP 数组。语法是这样的:

echo $form->data['Itemid']
于 2012-08-13T15:10:31.710 回答