Why not just iterate through the entire string and use is_numeric()...
function GetPhoneNumber($strPhoneNum)
{
$strDigits = "";
$len = strlen($strPhoneNum);
for ($i=0; $i < $len; ++$i)
{
if (is_numeric($strPhoneNum[$i]))
$strDigits .= $strPhoneNum[$i];
}
return($strDigits);
}
$strDigitsOnly = GetPhoneNumber("(123) 456-7890");
echo $strDigitsOnly;