这是Array& amp;的示例。对象:
$LObj = [
0 => (object) [
0 => 1,
1 => 'a',
3 => 'str',
],
1 => (object) [
0 => 2,
1 => 'a',
3 => 'str',
],
2 => (object) [
0 => 3,
1 => 'a',
3 => 'str',
],
1 => (object) [
0 => 4, //printme
1 => 'a',
3 => 'str',
],
'bonus' => (object) [
0 => '4',
'1' => 1,
'bonus' => 'str',
],
];
var_dump($LObj['bonus']);
echo $LObj['bonus']->0; // #1 how do you display '4' value?
echo $LObj['bonus']->1; // #2 how do you display 1 value?
echo $LObj['bonus']->bonus; // #3 is 'str'
我想使用任意一个循环(foreach)使用单行代码(如#3)显示每个#1,#2,#3。 #3显示正确,问题是#1& #2。我一直在寻找答案但却找不到答案。任何帮助都将受到高度赞赏,谢谢。