0

Here is my blade code to get otp input from the user

<input type="text" style="" id="digit-1" name="digit-1" data-next="digit-2" />
<input type="text" style="" id="digit-2" name="digit-2" data-next="digit-3" data-previous="digit-1" />
<input type="text" style="" id="digit-3" name="digit-3" data-next="digit-4" data-previous="digit-2" />
<input type="text" style="" id="digit-4" name="digit-4" data-next="digit-5" data-previous="digit-3" />
          

in my controller i want to get the merged value of the otp like this: ex- 1234 here is my controller code which shows error:

$user_given_otp=$request->digit-1.$request->digit-2.$request->digit-3.$request->digit-4;
  
sharif ahmed
  • 13
  • 1
  • 5
  • You should avoid hyphen characters for php class properties, still there is a way to access it, check this link: https://stackoverflow.com/questions/758449/how-do-i-access-this-object-property-with-a-hyphenated-name – Dharmang Jun 25 '20 at 11:35

1 Answers1

0

try

$user_given_otp=$request->get(digit-1).$request->get('digit-2').$request->get('digit-3').$request->get('digit-4');

or

$user_given_otp=$request->{'digit-1'}.$request->{'digit-2'}.$request->{'digit-3'}.$request->{'digit-4'};
N69S
  • 12,981
  • 3
  • 18
  • 33