I got this variable
$test = 'Alpha, Gamma, Beta';
What is the best practice to get this result? How do I add a certain word in between such as I did below add Rays.
Alpha Rays, Gamma Rays, Beta Rays
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this code piece
I can’t tell if it is “Best practice”, but it is a practice that works and is simple. You can probably make another solution which would give you better performance, and that might be “best practice” if performance is the issue.
But if simplicity is the way, this is good.
Edit:
Since some other answers are using
str_replace, I can give a working solution for that too: