Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TuffRivers's avatar

OK. Maybe i need to get back to basics here. These are the two dd($data) dumps i sent to front end, one is json, one is an array.

I should be iterating foreach over the SECOND dump?

@foreach ($data as $clients)
@foreach ($clients as $client)

{{ $client->ClientID }}

@endforeach 
@endforeach 

JSON

"[{"ClientID":64,"Name":"aas ","Soil Balance":0},{"ClientID":3092,"Name":"sdsa","Soil Balance":0},{"ClientID":39,"Name":"rrrt","Soil Balance":0},{"ClientID":3079,"Name":"rrrt","Soil Balance":0}]"

Array

array:85 [▼
  0 => array:3 [▼
    "ClientID" => 64
    "Name" => "aas "
    "Soil Balance" => 0
  ]
  1 => array:3 [▼
    "ClientID" => 3092
    "Name" => "sdsa"
    "Soil Balance" => 0
  ]
  2 => array:3 [▼
    "ClientID" => 39
    "Name" => "rrrt"
    "Soil Balance" => 0
  ]
jlrdw's avatar

Why don't you show an example of exactly the output you want.

Cronix's avatar
Cronix
Best Answer
Level 67

It's an array, not an object, so

{{ $client->ClientID }}

won't work

Try {{ $client['ClientID'] }}

1 like
Cronix's avatar

If the array is exactly as you have shown here

array:85 [▼
  0 => array:3 [▼
    "ClientID" => 64
    "Name" => "aas "
    "Soil Balance" => 0
  ]
  1 => array:3 [▼
    "ClientID" => 3092
    "Name" => "sdsa"
    "Soil Balance" => 0
  ]
  2 => array:3 [▼
    "ClientID" => 39
    "Name" => "rrrt"
    "Soil Balance" => 0
  ]

and assuming you're passing it to the view as $data

@foreach($data as $client)
  {{ $client['ClientID'] }}
@endforeach 
1 like
Nash's avatar

The inner loop has an associative array. Take a look at the very first example by @Cronix and how he loops through the two arrays. That is the right answer.

Edit: or look at his reply above this one, it's actually even better if you only want the client ID.

1 like
TuffRivers's avatar

@Cronix @Nash @jlrdw Personally would like to thank each of you especially cronix and jl for actually staying this entire time and not berating me lmao

So, that final bit of wisdom from cronix (or logic, probably logic because i lack it)

This is the code that worked.

My Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;

class LiabilityReportController extends Controller
{
    public function index(){

    $balance = DB::select('CALL sp_GetBalance()');

    $arr = json_encode($balance, true);

    $data = json_decode($arr, true);

  return view('liability-report.index', compact('data'));

}

}

My View (stripped it down to just this even in my index file)

@foreach ($data as $clients)


{{ $clients['Name'] }}

@endforeach

My Result in browser

ACA



ACD



PGX



STDS

Again, thank you for this two day journey !!!!

Previous

Please or to participate in this conversation.