Good day, Im very confused why I keep on getting an undefined error whenever I tried to use '$x->split' when iterating through my array.
dd
$divs = array(3) {
["items"]=>
array(4) {
[0]=>
object(stdClass)#247 (13) {
["type"]=>
int(6)
["description"]=>
NULL
["transactionType"]=>
string(4) "Bill"
["account_xid"]=>
int(4)
["gt_xid"]=>
int(1)
["u_xid"]=>
int(2001)
["po_xid"]=>
int(0)
["debit"]=>
float(144)
["credit"]=>
float(0)
["date_at"]=>
string(19) "2014-10-17 19:37:50"
["ref_no"]=>
string(2) "22"
["id"]=>
int(1)
["split"]=>
array(1) {
[0]=>
object(stdClass)#246 (1) {
["gt_xid"]=>
int(1)
}
}
}
[1]=>
object(stdClass)#248 (12) {
["type"]=>
int(6)
["description"]=>
NULL
["transactionType"]=>
string(4) "Bill"
["account_xid"]=>
int(4)
["gt_xid"]=>
int(2)
["u_xid"]=>
int(2001)
["po_xid"]=>
int(0)
["debit"]=>
float(0)
["credit"]=>
float(0)
["date_at"]=>
string(19) "2014-11-15 01:40:00"
["ref_no"]=>
string(0) ""
["id"]=>
int(4)
}
[2]=>
object(stdClass)#249 (13) {
["type"]=>
int(6)
["description"]=>
NULL
["transactionType"]=>
string(4) "Bill"
["account_xid"]=>
int(4)
["gt_xid"]=>
int(3)
["u_xid"]=>
int(2001)
["po_xid"]=>
int(0)
["debit"]=>
float(2980)
["credit"]=>
float(0)
["date_at"]=>
string(19) "2014-11-15 06:25:55"
["ref_no"]=>
string(4) "0998"
["id"]=>
int(6)
["split"]=>
array(1) {
[0]=>
object(stdClass)#254 (1) {
["gt_xid"]=>
int(3)
}
}
}
[3]=>
object(stdClass)#250 (13) {
["type"]=>
int(6)
["description"]=>
NULL
["transactionType"]=>
string(4) "Bill"
["account_xid"]=>
int(4)
["gt_xid"]=>
int(4)
["u_xid"]=>
int(2001)
["po_xid"]=>
int(0)
["debit"]=>
float(500)
["credit"]=>
float(0)
["date_at"]=>
string(19) "2014-11-15 06:37:07"
["ref_no"]=>
NULL
["id"]=>
int(8)
["split"]=>
array(1) {
[0]=>
object(stdClass)#256 (1) {
["gt_xid"]=>
int(4)
}
}
}
}
["accountName"]=>
string(15) "Inventory Asset"
["startingBalance"]=>
int(0)
}
the thing is Im using that kind of format when I iterate through my array on my Items. here's the way I do it.
@foreach($divs as $div)
{{ $div['accountNam'] }}
@foreach($div['items'] as $x)
{{ $x->description }}
{{ $x->date_at }}
{{ $x->transactionType }}
@endforeach
@endforeach
that code above works fine but when I add the 3rd inner loop
@foreach($divs as $div)
{{ $div['accountNam'] }}
@foreach($div['items'] as $x)
{{ $x->description }}
{{ $x->date_at }}
{{ $x->transactionType }}
@foreach($x->split as $z)
----I get error here---
@endforeach
@endforeach
@endforeach
I get this error: Undefined property: stdClass::$split
when I tried to dd($z->split)
I get this result which means that its not empty or doesnt exist
array(1) { [0]=> object(stdClass)#246 (1) { ["gt_xid"]=> int(1) } }
Can You Please help me find the thing that I am missing here. To make it work. I already tried using $z['gt_xid'] but it gives me another error : Cannot use object of type stdClass as array .. Thank you for spending time to read this. have a nice day ahead!
@? This specifically tells PHP to ignore any possible errors and warnings generated there, thus making it a LOT harder for you to debug the code. Get rid of them and you'll have a much easier time debugging.