How to Count two array in foreach loop

Posted 1 month ago by Kareimovich

Hi everybody here I have 2 paths so I return 2 arrays of tasks I need to count each array valuse So in last I get

[6, 4] not [10]

  @foreach ($Submpaths as $path)
     @foreach ($path->pathtags as $Tag)
            @php  $a=array();  @endphp 
             @foreach ($Tag->Tasks as $Task)  

                     @if (!in_array($Task->id,$a))
    
            <li class="list-group-item"> Task : {{ $Task->task_name }}  </li>

                 @php
                 array_push($a,$Task->id);
            @endphp
           
                         @endif
                     @endforeach
                  @endforeach
                @endforeach
           @endforeach

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.