title: Replace the last comma with an & sign
body: <p>I have searched everywhere but can't find a solution that works for me.</p>
  
  <p>I have the following:</p>
  
  <pre><code>$bedroom_array = array($studio, $one_bed, $two_bed, $three_bed, $four_bed);
  </code></pre>
  
  <p>For this example lets say:</p>
  
  <pre><code>$studio = '1';
  $one_bed = '3';
  $two_bed = '3';
  </code></pre>
  
  <p>I then use the implode function to put a comma in between all the values:</p>
  
  <pre><code>$bedroom_list = implode(", ", array_filter($bedroom_array));
  echo $bedroom_list;
  </code></pre>
  
  <p>This then outputs:</p>
  
  <p>1, 2, 3</p>
  
  <p>What I want to do is find the last comma in the string and replace it with an &amp;, so it would read:</p>
  
  <p>1, 2 &amp; 3</p>
  
  <p>The string will not always be this long, it can be shorter or longer, e.g. 1, 2, 3, 4 and so on. I have looked into using substr but am not sure if this will work for what I need?</p>