This might probably not solve your problem, but if the users were entering those numbers via an interface you have control over, e.g. a webform, then you could force them to enter the number in your predefined way, e.g. a dropdown with the prefixes etc

On Sun, Jul 24, 2011 at 11:22 PM, Michael Pedersen <sku@kaal.dk> wrote:
AH - yes of course..

Sometimes the most simple solutions are just too obvious to be seen - Thanks
(maybe its time to stop coding for the day - clearly my mind is not sharp)

code:
$phone = '254' . substr(preg_replace('/[^0-9]*/', '', $input), -9);

..
Mike



On 7/24/11 11:13 PM, Rad! wrote:
Personally I am a student of Occam's razor.

A mobile number (in Kenya at any rate) Is composed of 9 digits (barring the zero and/or country code)

So a regex that removes all non digits from a given number and then captures 9 digits from the end of line should work consistently.

You can then add the leading 0 or the country prefix in code


_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke

_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke



--
Regards,
Peter Karunyu
-------------------
Web Performance Evangelist
Make your website and web app faster.