I want to get balance from my array . here is the array below
stdClass Object
(
[id] => 2372
[cash_memo_id] => 2373
[date] => 2021-02-24
[customer_name] => A.T Corporation
[customer_code] => 9
[ship_to] => A.T Corporation
[truck_no] => 1
[total] => 328080.30
[total_due] => 328080.30
[balance] => 328080.30
)
This is the query below
$cartdata = DB::table('cart_manage')
->where('customer_code',$customer_code)
->first();
I am trying to get balance value using this way ...
$cartdata->balance;
but I greeting error
Trying to get property 'balance' of non-object
Please help me .
Thanks to All
My Answer:
1
[name] => John
[balance] => 100
)
To get the balance from this stdClass object in Laravel, you can access it using the arrow operator like this:
php
$object = new stdClass();
$object->id = 1;
$object->name = 'John';
$object->balance = 100;
$balance = $object->balance;
echo $balance; // Output: 100
You can also access the balance directly from the array if you have it stored in a variable like this:
php
$array = [
'id' => 1,
'name' => 'John',
'balance' => 100
];
$balance = $array['balance'];
echo $balance; // Output: 100
Rate this post
5 of 5 based on 9442 votesComments