5 months ago

array_merge(): Expected parameter 2 to be an array, string given

Posted 5 months ago by Rass21

I am trying to make a temperature converter, and I created a function inside a controller to request which conversion the user selects. However i get this error when I load my view "array_merge(): Expected parameter 2 to be an array, string given". This is my controller:


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TemperatureController extends Controller
    public function index(Request $request)
        $selectValue = $request->input('conversions');

        return view('temp', ['selectValue' => $selectValue]);

My route:

Route::get('temp', function() {
    return view('temp', '[email protected]');

And my view:



use Illuminate\Support\Facades\Input;

$fah = 30 * (9.0/5.0) + 32;



<form method="POST" action="temp">
    <input type="number" name="celsius" placeholder="Enter Temperature" step="any">
        <select name="conversions">
            <option value="select">Select Conversion</option>
            <option value="fahtocel">Fahrenheit to Celsius</option>
            <option value="celtofah">Celsius to Fahrenheit</option>
    <input type="submit" name="submit" value="Convert">




I haven't been able to find anything online. Why am I getting this error?

Please sign in or create an account to participate in this conversation.