quiz app,I am trying to access my choice0,choice1,choice2,choice3 named inputs. But i need to make my $request->choice be $request->choice1`` for the first one and$request->choice2``` for the second and same for choice3 and choice4. But this does not work, How would I be able to do this
public function update(Request $request, $id)
{
$question = Question::find($id);
$question->question = $request->question;
$i = 1;
foreach ($question->choice as $choice) {
$choicestring = "choice"+$i;
$choice = $request->choicestring;
dd($choice);
$i++;
}
}
I get the choice1 value when I access it normally thru $request->choice1. And echo $choicestring gives choice1
But when combined together which should be the equivalent of $request->choice1 the dd($choice) gives me
null