should be able to use this to manipulate what you want to do
<?
if(ereg("^\+([0-9]{2,3})([^0-9]+)(.+)$", $phone, $tmp))
$phone = "+".$tmp[1].".".$tmp[3];
else if(ereg("^(\+*)".$pcod."([^0-9]*)(.+)$", $phone, $tmp))
$phone = "+".$pcod.".".$tmp[3];
else if(ereg("^(\+*)([^0-9]*)(.+)$", $phone, $tmp))
$phone = "+".$pcod.".".$tmp[3];
else
$phone = "+".$pcod.".".$phone;
?>