title: Extract part of a string and append it to its end in PHP
body: <p>I have to take out some part of a string and append it to the end. I could do it with basic <code>str_replace()</code> and the <code>.</code> 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?</p>
  
  <p>Here is an example:</p>
  
  <pre><code>$initial = 'I like apples and mangoes same as you.';
  $final = 'I like same as you. apples and mangoes.';
  </code></pre>
  
  <p>In this case, I have moved everything between <code>like</code> and <code>same</code> to the end.</p>