Download the PHP package jsor/string-formatter without Composer
On this page you can find all versions of the php package jsor/string-formatter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package string-formatter
StringFormatter
Localized formatting of personal names, addresses and telephone numbers.
Note: At the moment, only a NameFormatter is available. Address and telephone formatters will follow.
Installation
Install the latest version with Composer.
Check the Packagist page for all available versions.
NameFormatter
The NameFormatter formats the appropriate representation of a person’s name for a locale by the given name parts.
The above example will output:
A custom pattern can be passed as the second argument to the constructor.
The above example will output:
Pattern
The pattern argument can contain any combination of characters and field descriptors.
The following field descriptor are supported.
%f
Family names.%F
Family names in uppercase.%g
First given name.%G
First given initial.%l
First given name with latin letters. In some cultures, eg on Taiwan it is customary to also have a first name written with Latin letters, although the rest of the name is written in another script.%o
Other shorter name, eg. "Bill".%m
Additional given names.%M
Initials for additional given names.%p
Profession.%d
Salutation, supporting the FDCC-sets conventions, with1
forname_gen
,2
forname_mr
,3
forname_mrs
,4
forname_miss
,5
forname_ms
.%s
Full Salutation, such as "Doctor".%S
Abbreviated salutation, such as "Mr." or "Dr."%t
If the preceding field descriptor resulted in an empty string, then the empty string, else a space.
Values
The array argument passed to format()
can define a value for each field
descriptor. The keys can be either the descriptor character or a named key.
The following keys are supported.
family_name
,family_names
orf
(for%f
)family_name_in_uppercase
,family_names_in_uppercase
orF
(for%F
)given_name
,given_names
org
(for%g
)given_initial
,given_initials
orG
(for%G
)given_name_with_latin_letters
,given_names_with_latin_letters
orl
(for%l
)other_shorter_name
,other_shorter_names
oro
(for%o
)additional_given_name
,additional_given_names
orm
(for%m
)initials_for_additional_given_name
,initials_for_additional_given_names
orM
(for%M
)profession
,professions
orp
(for%p
)salutation
,salutations
ord
(for%d
)full_salutation
,full_salutations
ors
(for%s
)abbreviated_salutation
,abbreviated_salutations
orS
(for%S
)
License
Copyright (c) 2015-2022 Jan Sorgalla. Released under the MIT license.