【发布时间】:2012-08-13 15:08:18
【问题描述】:
我有可以通过代码显示的数组:
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
我该怎么做?
谢谢!
雷维斯
【问题讨论】:
-
你试过什么? -- 此外,你已经得到了答案:
$form->data['Itemid']或$form->data->Itemid; -
if ($key == 'Itemid') { // 做点什么? }
-
@EliasVanOotegem:
$form->data->Itemid不是数组语法。 -
@drrcknlsn:我知道,但是由于操作显然使用了一个对象,并且结果看起来像查询返回的内容(或解析的 xml 文档,或者......),它很可能是实现
ArrayAccess接口的对象,在这种情况下$var->data->colName将是有效的