On Wednesday 15 November 2006 06:24, you wrote: > At 11/14/2006 03:17 PM, Børge Holen wrote: > >$number = 123456789 > > > >should print as following: > >var1: 12345 (and it is this lengt witch varies) > >var2: 67 > >var3: 89. > > You can also do this with a regular expression: > > $iNumber = '123456789'; > $sPattern = '/(\d+)(\d{2})(\d{2})$/'; > preg_match($sPattern, $iNumber, $aMatches); > > Then $aMatches contains: > > Array > ( > [0] => 123456789 > [1] => 12345 > [2] => 67 > [3] => 89 > ) > > The regexp pattern /(\d+)(\d{2})(\d{2})$/ means: > > (one or more digits) (two digits) (two digits) [end of string] > > preg_match > http://ca3.php.net/manual/en/function.preg-match.php > > Pattern Syntax > http://ca3.php.net/manual/en/reference.pcre.pattern.syntax.php > > Regards, > Paul Thanks. Its a much more sophisticated code with three values in one array, rather than my solution with 2 vars from the substr and one array with one value from explode. Never used preg_match like this before. =) -- --- 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