Skip to content

Commit 2653ef4

Browse files
committed
minor #18610 [Intl] Document support for ISO 3166-1 numeric codes (benr77)
This PR was merged into the 6.4 branch. Discussion ---------- [Intl] Document support for ISO 3166-1 numeric codes To accompany PR * symfony/symfony#51073 Commits ------- a9da7e0 Document support for ISO 3166-1 numeric codes
2 parents 46633f2 + a9da7e0 commit 2653ef4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

components/intl.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,33 @@ You may convert codes between two-letter alpha2 and three-letter alpha3 codes::
179179

180180
$alpha2Code = Countries::getAlpha2Code($alpha3Code);
181181

182+
Numeric Country Codes
183+
~~~~~~~~~~~~~~~~~~~~~
184+
185+
The :class:`Symfony\\Component\\Intl\\Countries` class also provides access to the
186+
numeric country codes according to the `ISO 3166-1 numeric`_ list::
187+
188+
use Symfony\Component\Intl\Countries;
189+
190+
\Locale::setDefault('en');
191+
192+
$numericCodes = Countries::getNumericCodes();
193+
// ('alpha2Code' => 'numericCode')
194+
// => ['AA' => '958', 'AD' => '020', ...]
195+
196+
$numericCode = Countries::getNumericCode('FR');
197+
// => '250'
198+
199+
$alpha2 = Countries::getAlpha2FromNumeric('250');
200+
// => 'FR'
201+
202+
$exists = Countries::numericCodeExists('250');
203+
// => true
204+
205+
.. versionadded:: 6.4
206+
207+
The support for numeric country codes was introduced in Symfony 6.4.
208+
182209
Locales
183210
~~~~~~~
184211

@@ -435,6 +462,7 @@ Learn more
435462
.. _`Unicode ISO 15924 Registry`: https://www.unicode.org/iso15924/iso15924-codes.html
436463
.. _`ISO 3166-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
437464
.. _`ISO 3166-1 alpha-3`: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
465+
.. _`ISO 3166-1 numeric`: https://en.wikipedia.org/wiki/ISO_3166-1_numeric
438466
.. _`UTC/GMT time offsets`: https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
439467
.. _`daylight saving time (DST)`: https://en.wikipedia.org/wiki/Daylight_saving_time
440468
.. _`ISO 639-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_639-1

0 commit comments

Comments
 (0)