![](/img/trans.png)
[英]How to increment the value of an array by 1 in a foreach-loop of another array in PHP
[英]laravel array value in foreach loop another array value how to show
// controller 代碼
$mtest = mtest::with('mycourse')->get();
//$mtest=$mtest->toarray();
print_r($mtest);
// controller 代碼
$mtest = mtest::with('mycourse')->get();
$mtest=$mtest->toarray();
print_r($mtest);
index.blade.php 代碼
@foreach($mtest as $us)
<tr>
<td>{{$us->tname}}</td>
**<td>{{$us->name}}</td>**
<td>{{$us->course_id}}</td>
<td>{{$us->qno}}</td>
@endforeach
在數組中的值[mycourse]=> array[0]=array(['id']
..... 我的問題如何獲取mycourse array value ->name= Ras exam
請幫幫我
不要轉換為數組。 這應該只是做你需要的。
<td>{{$us->mycourse->first()->name}}</td>
最后一次嘗試
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.