我有一个循环遍历我的多数组,但我需要使用刀片语法设置每个条目的样式。我试过用 php 回显 Html,但没有奏效。
这就是我在 Blade 语法中尝试做的事情
echo '<td>'.$key.'</td>';
大批
array:2 [▼
0 => {#173 ▼
+"Name": "Rama Berger"
+"StockName": "apple"
+"price": 100
+"Date": "2016-01-07 17:31:06"
}
1 => {#172 ▼
+"Name": "Rama Berger"
+"StockName": "apple"
+"price": 11
+"Date": "2016-01-07 20:00:38"
}
]
看法
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Name</th>
<th>Stock</th>
<th>Order Amount</th>
<th>Date</th><br>
</tr>
</thead>
<tbody>
@foreach($History as $Past)
@foreach($Past as $key)
<tr>
<td>{{$key}}</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
控制器
<?php
namespace App\Http\Controllers;
use \View as View;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Request;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class RequestController extends BaseController
{
public function GetHistory(){
$name = Auth::user()->name;
$History = DB::table('History')->select('Name', 'StockName', 'price', 'Date')->where('StockName', '=', 'apple')->get();
return view('pages.home')->with('History', $History);
}
}