print_r ?
$msg= "Data inserted for record id: {$row['record_id']}";
return redirect()->back()->with(compact('msg');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to return an array to blade file and display. but I am getting an error : " htmlspecialchars() expects parameter 1 to be string, array given "
here is my code:
$return = print_r('Data inserted for record id:' . $row['record_id'],true);
return redirect()->back()->with('msg', [$return]);
blade file: @if(session()->has('msg')) {{ session()->get('msg') }} @endif Thanks.
This is the solution that helped me with this issue.
@foreach(session()->get('msg') as $in)
<tr>
<td>{{$in}}</td>
</tr>
@endforeach
Please or to participate in this conversation.