I have to take out some part of a string and append it to the end. I could do it with basic str_replace()
and the .
operator. However, the part I want to extract is not constant. So, I need to get and store it somewhere before I can append it. How should I proceed?
Here is an example:
$initial = 'I like apples and mangoes same as you.';
$final = 'I like same as you. apples and mangoes.';
In this case, I have moved everything between like
and same
to the end.