Php 表输出额外<;td>';正在观看

Php 表输出额外<;td>';正在观看,php,laravel,laravel-4,html-table,Php,Laravel,Laravel 4,Html Table,我试图在视图中输出一个多维数组,但是得到了一些奇怪的输出。以下是我的屏幕抓图: 以下是我正在使用的代码: </tr> @endforeach </tbody> </table> @endforeach 我认为这与我的if-else声明有关,但我已经在这个问题上纠缠了一段时间。任何帮助都将不胜感激!谢谢 编辑:根据要求,这是我的数据结构,它是var_dump:没有数据结构很难说,但我想问题在于数据结构和嵌套的foreach 在检查$s

我试图在视图中输出一个多维数组,但是得到了一些奇怪的输出。以下是我的屏幕抓图:

以下是我正在使用的代码:

    </tr>
  @endforeach



  </tbody>
</table>

@endforeach
我认为这与我的if-else声明有关,但我已经在这个问题上纠缠了一段时间。任何帮助都将不胜感激!谢谢


编辑:根据要求,这是我的数据结构,它是var_dump:

没有数据结构很难说,但我想问题在于数据结构和嵌套的foreach

在检查$status时,循环遍历数组。第一次循环数组时,
$status==1
,但每次检查状态时都会写入td

@foreach ($count as $status => $c)

    @if($status == 2)
        <td><a href="#">{{$c}}</a></td>
    @else
        <td>&nbsp;</td>
    @endif

    ...

@endforeach
第二次通过时,假设
$status=2
,您将获得:

<td><a href="#">{{$c}}</a></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
然后像这样只浏览一次数据。我将代码提取到一个部分中,但您可以继续内联操作

page.blade.php

<table class="table tablesorter" id="tblAffs">
    <thead>
        <tr class="tblhead">
            <th>AM</th>
            <th>Qualified Prospect</th>
            <th>Unqualified Prospect</th>
            <th>Contacted</th>
            <th>Converted To Account</th>
            <th>Pending Integration</th>
            <th>Revenue Generating</th>
        </tr>
    </thead>
    <tbody>

        $totalCount should be a collection of $person
        @foreach ($totalCount as $name => $totals)

        <tr>
          <td>
            {{$name}}
            <br>
            <a href="#">Closed</a>
        </td>

        @include('partial.item', 'count' => $totals->qualifiedProspectCount)
        @include('partial.item', 'count' => $totals->unqualifiedProspectCount)
        @include('partial.item', 'count' => $totals->contactedCount)
        @include('partial.item', 'count' => $totals->convertedToAccountCount)
        @include('partial.item', 'count' => $totals->pendingIntegrationCount)
        @include('partial.item', 'count' => $totals->revenueGeneratingCountCount)

    </tr>
    @endforeach



</tbody>
@if($count > 0)
    <td><a href="#">{{{$count}}}</a></td>
@else
    <td>&nbsp;</td>
@endif

是
合格前景
无条件的前景
联络
转帐
待整合
创收
$totalCount应该是$person的集合
@foreach($totalCount作为$name=>$totals)
{{$name}

@包括('partial.item','count'=>$totals->qualifiedProspectCount) @包括('partial.item','count'=>$totals->unqualifiedProspectCount) @包括('partial.item','count'=>$totals->contactedCount) @包括('partial.item','count'=>$totals->convertedToAccountCount) @包括('partial.item'、'count'=>$totals->pendingtegrationcount) @包括('partial.item','count'=>$totals->RevenueGenerationCountCountCount) @endforeach

partial/item.blade.php

<table class="table tablesorter" id="tblAffs">
    <thead>
        <tr class="tblhead">
            <th>AM</th>
            <th>Qualified Prospect</th>
            <th>Unqualified Prospect</th>
            <th>Contacted</th>
            <th>Converted To Account</th>
            <th>Pending Integration</th>
            <th>Revenue Generating</th>
        </tr>
    </thead>
    <tbody>

        $totalCount should be a collection of $person
        @foreach ($totalCount as $name => $totals)

        <tr>
          <td>
            {{$name}}
            <br>
            <a href="#">Closed</a>
        </td>

        @include('partial.item', 'count' => $totals->qualifiedProspectCount)
        @include('partial.item', 'count' => $totals->unqualifiedProspectCount)
        @include('partial.item', 'count' => $totals->contactedCount)
        @include('partial.item', 'count' => $totals->convertedToAccountCount)
        @include('partial.item', 'count' => $totals->pendingIntegrationCount)
        @include('partial.item', 'count' => $totals->revenueGeneratingCountCount)

    </tr>
    @endforeach



</tbody>
@if($count > 0)
    <td><a href="#">{{{$count}}}</a></td>
@else
    <td>&nbsp;</td>
@endif
@if($count>0)
@否则
@恩迪夫
编辑 所以这会让你以后陷入各种各样的麻烦,但你来了

@foreach ($totalCount as $name => $count)

    <tr>
        <td>
            {{$name}}
            <br>
            <a href="#">Closed</a>
        </td>

        @if(isset($count[2]))
            <td><a href="#">{{ $count[2] }}</a></td>
        @else
            <td>&nbsp;</td>
        @endif
        @if(isset($count[1]))
            <td><a href="#">{{ $count[1] }}</a></td>
        @else
            <td>&nbsp;</td>
        @endif

        // and so on ...

    </tr>
@endforeach
@foreach($totalCount作为$name=>$count)
{{$name}

@如果(isset($count[2])) @否则 @恩迪夫 @如果(isset($count[1])) @否则 @恩迪夫 //等等。。。 @endforeach

我建议你去看看,有很多方法可以做你想做的事情,比你现在做的要容易得多。尽管感觉更快。不是的。

你能添加一个例子说明多维数组是如何格式化的吗?我已经包括了我的数据结构和它的变量转储。我想我可以让它工作,我有它,但就是不能得到表。看一看,告诉我你的想法。因为我不确定你所想的和我实际做的是什么。谢谢