Thanks, but I'd already thought of that... Problem is, the string can be of many different formats, it's the format of a phone number, so for example:
Now it depends on whether your input format is variable. If it is pretty much fixed at the number of digits for the given country, you could use [man]preg_replace/man with something like this:
<?php
$phoneFormats = array(
'GB' => '(\d{3})(\d{6})',
'US' => '(\d{3})(\d{3})(\d{4})',
'DE' => '(\d{4})(\d{4})(\d{2})'
);
$formatReplacements = array(
'GB' => '\1 \2',
'US' => '\1-\2-\3',
'DE' => '\1-\3-\3'
);
$country = 'GB';
$number = '01234567899';
echo preg_replace('/' . $phoneFormats[$country] . '/', $formatReplacements[$country], $number);
?>