project3 Posted March 6, 2008 Share Posted March 6, 2008 I want to remove the first 2 digits of a number. like 2007 I want to be just the last 2 digits. I know how to use replace but it i take out the 20 if its 2020 that wont work. How do i get this done? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/94780-remove-first-2-digits/ Share on other sites More sharing options...
Psycho Posted March 6, 2008 Share Posted March 6, 2008 Well, do you want to remove the first two digits or keep the last two digits? those are two different things - unless we make the assumption that the value will always be four characters long. This will return the last two charcters from a value: $last_two = substr($original_value, -2); Quote Link to comment https://forums.phpfreaks.com/topic/94780-remove-first-2-digits/#findComment-485332 Share on other sites More sharing options...
project3 Posted March 6, 2008 Author Share Posted March 6, 2008 Well, do you want to remove the first two digits or keep the last two digits? those are two different things - unless we make the assumption that the value will always be four characters long. This will return the last two charcters from a value: $last_two = substr($original_value, -2); Thanks!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/94780-remove-first-2-digits/#findComment-485335 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.