我有可以通过代码显示的数组:
foreach($form->data as $key => $value){
echo 'Key is '.$key.' and Value is '.$value.'<br />';
}
Run Code Online (Sandbox Code Playgroud)
我得到以下显示:
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
Run Code Online (Sandbox Code Playgroud)
但我只需要显示[Itemid]其中的值,在这种情况下114
我该怎么做?谢谢!Raivis
echo $form->data['Itemid'];
Run Code Online (Sandbox Code Playgroud)
或者如果你的意思是在foreach循环中(因为你还有其他东西要做),那么使用:
foreach($form->data as $key => $value) {
if( $key === 'Itemid' )
echo $form->data['Itemid'];
}
Run Code Online (Sandbox Code Playgroud)