How would I get PHP to read the only the last digit of a number?
I want to insert a number, have PHP read the last digit of it, and then take a specific action depending on that last digit. I looked through the string functions list on php.net but had no luck finding what I was looking for.
If anyone knows the function I'm trying to find, please post it. I appreciate all your help.
PHP string functions question
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
You could also do a %10.
Code: Select all
$lastDigit = $number % 10;Hmm...You could also do a %10.
Code: Select all
$number = '+38(095) 123-1139';
$lastDigit = $number % 10; // $lastDigit = WHAT?