5

i want to concatinate select_teacherActivity with variable $week_no and variable $activity as one word

 $Activity->description = $request->input('select_teacherActivity".$week_no.".$activity');
3
  • how can i do that concatenation? Commented May 16, 2017 at 8:35
  • Use + for variables and dot for string Commented May 16, 2017 at 8:36
  • You could change input('select_teacherActivity".$week_no.".$activity'); to input("select_teacherActivity$week_no$activity"); (in double quotes) Commented May 16, 2017 at 8:40

2 Answers 2

5

if you want get a string you should use concat operation '.' 'select_teacherActivity".$week_no . $activity; this should work if $week_no and $activity sting or there have implemented toString magic method.

Sign up to request clarification or add additional context in comments.

Comments

2

There are multiple syntax errors in the code shared:

All opening quotes should close with the corresponding type of quote:

'select_teacherActivity" //Wrong
'select_teacherActivity' //Right
.". //Wrong
."".//Right (but unnecessary) 

There is also have a stray ' at the end. Full code:

$Activity->description = $request->input('select_teacherActivity'.$week_no.$activity);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.