title: How do I get the first and the last digit of a number in PHP?
body: <p>How can I get the first and the last digit of a number? For example 2468, I want to get the number 28. I am able to get the ones in the middle (46) but I can't do the same for the first and last digit.</p>
  
  <p>For the digits in the middle I can do it </p>
  
  <pre><code>$substrmid = substr ($sum,1,-1); //my $sum is 2468
  echo $substrmid;
  </code></pre>
  
  <p>Thank you in advance.</p>