On Wednesday 15 November 2006 12:42, Robin Vickery wrote: > On 15/11/06, Aaron Koning <aaronkoning@xxxxxxxxx> wrote: > > Assuming var1 and var2 only ever use the last four numbers (untested): > > > > $length = strlen($number); // get string length > > $var1 = substr($number,0,$length-4); // get number until only 4 numbers > > are left > > $var2 = substr($number,$length-4,2); // get 3rd and 4th last numbers. > > $var3 = substr($number,$length-2,2); // get last two numbers. > > No need to work out the length of the string. > > $var1 = substr($number, 0, -4); > $var2 = substr($number, -4, 2); > $var3 = substr($number, -2); Why do I suddenly feel stupid ;D magnificent! Easier than the preg_match solution, but not as compact. -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php