Skip to content Skip to sidebar Skip to footer

Htmlspecialchars() Expects Parameter 1 To Be String, Array Given In Laravel

I have got this error in my Laravel blade template htmlspecialchars() expects parameter 1 to be string, array given I have tried to convert the array into string in blade templat

Solution 1:

{{}} will be converted to echo() by Blade template engine. And you're trying to echo the array as a string.

You may convert it to JSON:

varvalue = '{{ json_encode($sliderImageDataArray) }}';

If it's a Laravel collection or a model:

varvalue = '{{ $sliderImageData->toJson() }}';

Post a Comment for "Htmlspecialchars() Expects Parameter 1 To Be String, Array Given In Laravel"