i want to extract last four characters of the string how can
Moderator: General Moderators
-
lokesh_kumar_s
- Forum Commoner
- Posts: 48
- Joined: Mon Apr 13, 2009 5:39 am
- Contact:
i want to extract last four characters of the string how can
i want to extract last four characters of the string how can i do it. and also i want to conver that last four chars to int and want to increment it by 1. how can i do it
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: i want to extract last four characters of the string how can
There are several ways to do it. Here is one way:
You probably don't need the intval() because PHP will convert to a number for the + operator.
Code: Select all
$new_number = intval(substr($string, -4)) + 1;(#10850)