skip to Main Content

how I can foreach data under foreach data came from database like this bellow.

{"details":"Up to 5 Groups / Month","details":"Up to 30 CSV File Importing / 
Month","details":"Up to 5 SMTP Config","details":"Up to 5 Email Template Can Make and 
Edit","details":"Up to 30 Writer Call / Month","details":"24x7 Support"}

This array data stored on database in $TABALE_1 (model) on FSLS (row) so I foreach $TABLE_1 like this.

@foreach ($TABLE_1 as $lists)
Name: {{$lists->name}}

 @foreach($lists->FSLS as $fLists)
   Name_2: {{$fLists['details']}}
 @endforeach

@endforeach

I don’t How I do it, I just shear how I try, please help if you understand.

2

Answers


  1. you get the object you need an array ( example object {} to array [] )

    https://www.php.net/manual/en/function.get-object-vars.php

    Login or Signup to reply.
  2. Just typecast it, like this.

    @foreach ($TABLE_1 as $lists)
    Name: {{$lists->name}}
    
     @foreach($lists->FSLS as $fLists)
       Name_2: {{ (array)$fLists['details'] }}
     @endforeach
    
    @endforeach
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search