当在Smarty中打印出数组(复杂)时(从{$myarray->get_fields()|print_r}打印),我得到以下列表:
Array
(
[44] => stdClass Object
(
[id] => 44
[name] => Address 2
[type] => textbox
[max_length] => 255
[create_date] => 2013-03-25 10:02:02
[modified_date] => 2013-03-25 10:02:02
[item_order] =>
[admin_only] => 0
[public] => 1
[dropdown_data] =>
[data] =>
[fielddef_id] => 44
[value] => Halifax
)
[47] => stdClass Object
(
[id] => 47
[name] => Address 3
[type] => textbox
[max_length] => 255
[create_date] => 2013-03-25 10:02:56
[modified_date] => 2013-03-25 10:02:56
[item_order] =>
[admin_only] => 0
[public] => 1
[dropdown_data] =>
[data] =>
[fielddef_id] => 47
)
[50] => stdClass Object
(
[id] => 50
[name] => Address 4
[type] => textbox
[max_length] => 255
[create_date] => 2013-03-25 10:03:40
[modified_date] => 2013-03-25 10:03:40
[item_order] =>
[admin_only] => 0
[public] => 0
[dropdown_data] =>
[data] =>
[fielddef_id] => 50
)
)
我想直接打印出在数组(44)中set的第一个数组的[value]字段。基本上,我想打印[44]->name,但不确定如何直接做到这一点,而不需要通过一系列if/else语句迭代foreach循环。
就像:
$array_name[44]['name']
或
$array_name[44]->name