Page 1 of 1
i want to extract last four characters of the string how can
Posted: Tue Jun 16, 2009 3:10 am
by lokesh_kumar_s
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
Re: i want to extract last four characters of the string how can
Posted: Tue Jun 16, 2009 3:30 am
by Christopher
There are several ways to do it. Here is one way:
Code: Select all
$new_number = intval(substr($string, -4)) + 1;
You probably don't need the intval() because PHP will convert to a number for the + operator.