我有可以通过代码显示的数组:
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
我该怎么做?
谢谢!
Raivis
答案 0 :(得分:5)
echo $form->data['Itemid'];
或者如果你的意思是在foreach循环中(因为你还有其他东西要做),那么使用它:
foreach($form->data as $key => $value) {
if( $key === 'Itemid' )
echo $form->data['Itemid'];
}
答案 1 :(得分:1)
您应该阅读PHP arrays。语法是这样的:
echo $form->data['Itemid']