0

I have a subpage that draws the letters for each table. For example, I give 1, 2, 3, 4, 5 and a, b, c. Below is the code that processes the result:

@extends('layout')
@section('content')
    <div class="card mt-5">
        <div class="card-header" style="z-index: 1000;">
            <h2>Results {{response()->json([$teams_json])->getContent()}}</h2>
        </div>     
    </div>
@endsection

The result of the JSON response:

Result: [{"a":["2","3"],"b":["1","5"],"c":["4"]}]

How can I format my result to look like this?

Result:
   - a: 2,3
   - b: 1,5
   - c: 4
1
  • You can't just magically convert one format to the other without a little help. Are you referring to pretty print with json encode? Commented Jul 18, 2020 at 14:06

1 Answer 1

1

You'll have to loop it and print them the way you wish. Since you're using Blade, you can use @foreach.
Try the following:

@extends('layout')
@section('content')
    <div class="card mt-5">
        <div class="card-header" style="z-index: 1000;">
            <h2>Results {{response()->json([$teams_json])->getContent()}}</h2>
            @foreach ($teams_json as $team => $no)
                {{ $team }}: {{ implode($no) }}
            @endforeach
        </div>     
    </div>
@endsection
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.