Distinguish countries with same calling code #2306 #1256

This commit is contained in:
Kijin Sung 2024-04-15 01:41:13 +09:00
parent 97460af76a
commit 5b66613d83
2 changed files with 35 additions and 6 deletions

View file

@ -247,9 +247,20 @@ class Value
return is_array($value) ? implode('-', $value) : $value;
case 'tel_intl':
case 'tel_intl_v2':
$country_code = $value[0] ?? '';
$phone_number = implode('-', array_slice((array)$value, 1));
return $value ? "(+{$country_code}) {$phone_number}": '';
if (is_array($value) && count($value))
{
$country_code = $value[0];
$phone_number = array_slice((array)$value, 1);
if (count($phone_number) && ctype_alpha(end($phone_number)))
{
array_pop($phone_number);
}
return sprintf('(+%d) %s', $country_code, implode('-', $phone_number));
}
else
{
return '';
}
case 'homepage':
case 'url':
$display = mb_strlen($value, 'UTF-8') > 60 ? mb_substr($value, 0, 40, 'UTF-8') . '...' . mb_substr($value, -10, 10, 'UTF-8') : $value;