Support the ongoing development of Laravel.io →
Eloquent Views Blade

so i do eager loading and it returned 1 array inside array like this

array(3) {
  [0]=>
  array(6) {
    ["id"]=>
    int(5)
    ["name"]=>
    string(20) "Berita Internasional"
    ["jumlah"]=>
    int(0)
    ["created_at"]=>
    string(20) "-0001-11-30 00:00:00"
    ["updated_at"]=>
    string(19) "2014-10-30 03:14:04"
    ["artikel"]=>
    array(0) {
    }
  }
  [1]=>
  array(6) {
    ["id"]=>
    int(6)
    ["name"]=>
    string(16) "Berita Teknologi"
    ["jumlah"]=>
    int(0)
    ["created_at"]=>
    string(20) "-0001-11-30 00:00:00"
    ["updated_at"]=>
    string(19) "2014-11-05 07:29:47"
    ["artikel"]=>
    array(0) {
    }
  }
  [2]=>
  array(6) {
    ["id"]=>
    int(7)
    ["name"]=>
    string(14) "Berita Ekonomi"
    ["jumlah"]=>
    int(2)
    ["created_at"]=>
    string(20) "-0001-11-30 00:00:00"
    ["updated_at"]=>
    string(20) "-0001-11-30 00:00:00"
    ["artikel"]=>
    array(0) {
    }
  }
}

so as you can see ["artikel"] is containing array (althougth in this code example i make it empty for easy read but i will contain something)

how to echo out ["artikel"] part for each array?

Last updated 2 years ago.
0

I imagine it would look like:

<?php

foreach ($array as $myVar) { echo $myVar->artikel; }

Last updated 2 years ago.
0

jeffreydavidson said:

I imagine it would look like:

<?php foreach ($array as $myVar) { echo $myVar->artikel; }

yes that what i first do, but when i do that(the same query which mean $myvar->artikel contain nothing) it return the artikel .... it really weird =.=

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

t0n1zz t0n1zz Joined 8 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.