2 回答

TA貢獻(xiàn)1813條經(jīng)驗 獲得超2個贊
您需要循環(huán)遍歷結(jié)果。結(jié)果是一個數(shù)組。
更好的方法是使用 $request->getContent()
但是使用你的代碼
public function editUserPermissions(Request $request, $id) {
foreach($request->all() as $key => $value) {
$decode = json_decode($value);
foreach($decode as $decoded) {
echo $decoded['id'];
}
}
}

TA貢獻(xiàn)1744條經(jīng)驗 獲得超4個贊
public function editUserPermissions(Request $request, $id) {
$bodys = $request->body;
foreach($bodys as $key => $body) {
//$key give current index of array
$body[$key]['id'] //this give id
$body[$key]['name'] //this give name
}
}
- 2 回答
- 0 關(guān)注
- 157 瀏覽
添加回答
舉報