【发布时间】:2020-08-17 03:52:51
【问题描述】:
我需要从刀片视图中的数组访问一个值。 我来自控制器的数组:
array:2 [▼
"chartAllAlarm" => alarmDashboardChart {#298 ▶}
"prodCounter" => array:1 [▼
0 => {#303 ▼
+"production": 3580
+"preProduction": 0
+"test": 0
+"maintenance": 6
+"decommissioned": 403
}
] ]
我的看法:
<h3 class="font-weight-semibold mb-0">{{ $prodCounter[production] }}</h3>
Laravel 中的错误:
使用未定义的常量生产 - 假设“生产”(观点:
有人可以帮我吗?
【问题讨论】:
-
您错过了
$prodCounter[production]上的报价。试试$prodCounter['production'] -
但是如果你显示的是
$prodCounter的转储,你必须访问$prodCounter['prodCounter'][0]->production之前的先前索引并访问生产属性,因为你有一个对象 -
使用 {{ $prodCounter['prodCounter'][0]->production }} Laravel 说:未定义索引:prodCounter(查看:
-
嗯...然后试试
$prodCounter[0]->production
标签: arrays laravel laravel-blade