【发布时间】:2012-04-10 13:23:39
【问题描述】:
There is almost identical question,但我不知道该怎么做。
我刚开始使用 OO PHP,我的班级中有这个功能:
public function show() {
foreach($this->data['fields'] as $field) {
$type = $field['type'];
echo $type;
}
}
这是输入数据:
my_function('id',
array(
'foo' => 'bar',
'bar' => 'foo',
'fields' => array(
'type' => 'my_type',
'foo' => 'bar',
'etc.' => 'value'),
),
);
当然echo $field['type'] 只返回my_type (m) 的第一个字母。
我不能只使用echo $field,因为我在这个数组下有多个键,它返回my_typebarvalue 而不是my_type,$field[0] (mbv) 也是如此。我该怎么办?
【问题讨论】: