Need to get last digit of number - what's most efficient way?
Posted on 2014-01-02
I have a value:
$overall = "598397"; //for example
I need to get the last digit of that.
I've done a bit of research and have found two solutions commonly bantered about:
$last_digit = $overall % 10;
$last_digit = substr($overall, -1);
Which is the most efficient way to do this?
$overall will always be positive, will be '0' sometimes, and can grow quite large (low millions possible),
Thanks for any thoughts on this,