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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php