0

array data enter image description here

my code in index.blade.php

 <tr>
    @php
        $filter_date = \Carbon\Carbon::parse(request()->query('filter_date'))->format('Y-m-d');
        $end_date = \Carbon\Carbon::parse(request()->query('end_date'))->format('Y-m-d');

     $dateRangePeriod = \Carbon\CarbonPeriod::create($filter_date, $end_date);
     $dateRange = [];
     
     foreach ($dateRangePeriod as $key => $date) {
           $dateRange[] = $date->format('d  F');
     }

    //return array :
    //dd($dateRange);

  @endphp
      
   <th colspan="4" class="text-center"> {{ $dateRange}}</th>

</tr>

i want to display array of data from date and to date in laravel view line. when i call data {{ $dateRange}} i get error: TypeError:htmlspecialchars(): Argument #1 ($string) must be of type string, array given. how to solve my problem, help me, thanks.

1
  • 1
    you need to loop through $dateRange in order to display it on frontend. Commented Mar 7, 2022 at 4:20

1 Answer 1

2

Can you try changing your th tag <th colspan="4" class="text-center"> {{ $dateRange }}</th> to:

@foreach($dateRange as $date)
   <th class="text-center">{{ $date }}</th>
@endforeach
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.