📜  将表单数据请求转换为 json laravel - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:21.543000             🧑  作者: Mango

代码示例1
$collect = []; // empty array for collect customised inputs

foreach($request->all() as $input_key => $input_value){ // split input one by one

     $collect[] = array( //customised inputs
            "id" => $input_key,
            "value" => $input_value

     );
} 

$result = json_encode($collect); //convert to json