Php 如何在Laravel中将阵列数据从控制器传递到刀片服务器

Php 如何在Laravel中将阵列数据从控制器传递到刀片服务器,php,Php,我想将索引号为1的变量$matches5传递给我的视图,这是控制器中的getData函数 public function getData($txt){ if (preg_match("/berkedudukan di\s+(\w*(?:\W*\w)*)\W*selanjutnya disebut sebagai PIHAK\W*KESATU/", $txt, $matches5)) { } return view('mou', ['inputMitra

我想将索引号为1的变量$matches5传递给我的视图,这是控制器中的getData函数

public function getData($txt){
    if (preg_match("/berkedudukan di\s+(\w*(?:\W*\w)*)\W*selanjutnya disebut sebagai PIHAK\W*KESATU/", $txt, $matches5)) {
    }
    return view('mou', ['inputMitra' => $matches5[1]]);
}
然后,我想把$matches5放到表单中的值中

<form method="GET" action="/upload" name="getForm">
    <div class="form-group mt-5">
        <label for="inputMitra">Mitra Kerjasama</label>
        <input type="text" class="form-control" id="inputMitra" placeholder="Mitra Kerjasama" value="{{ $inputMitra }}">

克雅萨马米特拉酒店

为什么这段代码为$inputMitra获取错误未定义变量?

嗨,Rangaa,欢迎使用堆栈溢出:)如果您使用var_dump($matches5),您会得到什么?学习调试。因此,在函数中的
返回之前使用
dd($matches5[1])
查看发送到刀片服务器的内容,如果是空的,则向上一级,然后
dd($matches5)