error solved

Fix – htmlspecialchars() expects parameter 1 to be string, array given


If you are getting htmlspecialchars() expects parameter 1 to be string, array given error, this article will help you fix the issue.

Consider the example below:

@foreach($data->ac['0'] as $link)
    <a href="{{ $link['url'] }}">This is a link</a>
@endforeach

When you use a blade echo {{ $data }} it will automatically escape the output. It can only escape strings.  In the snippet above data $data->ac is an array and $data is an object, neither of which can be echoed as is. You need to be more specific of how the data should be outputted.

If you  if you intend to send the full array from the HTML to the controller, can use this:

<input type="hidden" name="quotation" value="{{ json_encode($quotation,TRUE)}}">

and update your controller like below:

public function Get(Request $req) {

    $quotation = array('quotation' => json_decode($req->quotation));

   }

Share on social media

//