Building an application for UK & Ireland only but potentially it might extend to other countries. We have built an API and I\'m trying to decided how A) to store phone n
?php
$array = array
(
'0871231234',
'087 123 1234',
'087-1231234',
'+353871231234'
);
foreach($array as $a)
if(preg_match("/(^[0-9]{10}$)|(^[0-9]{3}\ [0-9]{3}\ [0-9]{4}$)|(^[0-9]{3}\-[0-9]{7}$)|(^\+353[0-9]{9}$)/", $a))
{
// removes +35
$a = preg_replace("/^\+[0-9]{2}/", '', $a);
// removes first number
$a = preg_replace("/^[0-9]{1}/", '', $a);
// removes spaces and -
$a = preg_replace("/(\s+)|(\-)/", '', $a);
$a = "00353".$a;
echo $a."\n";
}
?>