I was using arrays to pass data back to a view from a controller, but now have switched to using just strings, however this error pops up.
" array_merge(): Argument #2 is not an array "
I'm not even using an array anymore, and i've done php artisan clear:cache incase there was some cache I didn't know about. I'm new to laravel but all the results I find are dealing with people incorrectly using arrays, whereas i'm just passing a simple string.
Can somebody please help? Below is my code
section of code in controller
else {
$result = 'That email belongs to an existing referrer.';
return view('admin.invalidReferrer', $result);
section of code in invalidReferrer.blade.php @extends('admin.admin')
@section('results')
<h4>{{ $result }}</h4>
@stop
previous controller solution
else {
$result = ['That email belongs to an existing referrer.'];
return view('admin.invalidReferrer', compact('result'));
previous blade solution
@section('results')
<h4>{{ $result[0] }}</h4>
@stop
Just use the previous solution but remove the superfluous array assignment.
Instead of using:
$result = ['That email belongs to an existing referrer.']; // shorthand array assignment of string to index 0
// ^ unneeded array assignment ^
Just assign the string directly:
$result = 'That email belongs to an existing referrer.';
return view('admin.invalidReferrer', compact('result'));
Then use the imported data normally as you would:
@section('results')
<h4>{{ $result }}</h4>
@stop
Just follow this instructions:
fixed for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.