use*_*668 6 php laravel laravel-5
如果集合是从数组创建的:
$collection = collect();
$collection->push([
'var1'=>'value1',
'var2'=>'value2'
]);
Run Code Online (Sandbox Code Playgroud)
是否有可能以类似于雄辩集合属性的方式获取特定键的值?
$collection->var1
Run Code Online (Sandbox Code Playgroud)
不,但你绝对可以做类似的事情
$collection->first(function($value, $key) {
return $key == 'var1';
});
Run Code Online (Sandbox Code Playgroud)
或者只是@AlexeyMezenin 的建议。
$collection[0]['var1'];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
54337 次 |
最近记录: |