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?
I imagine it would look like:
<?php
foreach ($array as $myVar) { echo $myVar->artikel; }
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 =.=
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community