Level 67
Already answered in your other existing thread. You left the $ off of $choicestring.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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;
echo $request->choice1;
foreach ($question->choice as $choice) {
$choicestring = "choice".$i;
echo $choicestring;
$choice = $request->choicestring;
dd($choice);
$i++;
}
}
the first echo gives me the value of the requests choice1 correctly and the echo of $choicestring gives me the value "choice1" which is correct but when I use them combined in $choice I get null when I echo/dd it
Already answered in your other existing thread. You left the $ off of $choicestring.
Please or to participate in this conversation.