Skip to content

Novis\Intl\ListFormat::Type

The words ListFormat::join uses to join the items of a list.

ListFormat::Type is declared in the class Novis\Intl\ListFormat.

You pass a ListFormat::Type as type:

  • And writes "tea, coffee, and water" in English. This is the default.
  • Or writes "tea, coffee, or water", for a choice.
  • Unit joins the parts of one amount, such as "5 feet, 11 inches".

The words and the commas come from the locale. German writes "Tee, Kaffee und Wasser", with no comma before "und".

Examples

And or unit

<?nvs
// Shows how each `ListFormat::Type` joins the same three items in English.
use Novis\Intl\ListFormat;
array<array<string>> $lists = [['tea', 'coffee', 'water']];
echo ListFormat::join($lists, 'en', { type: ListFormat::Type::And })[0], "\n";
echo ListFormat::join($lists, 'en', { type: ListFormat::Type::Or })[0], "\n";
// `Unit` joins amounts, such as the parts of a length.
echo ListFormat::join([['5 feet', '11 inches']], 'en', { type: ListFormat::Type::Unit })[0], "\n";
Output
tea, coffee, and water
tea, coffee, or water
5 feet, 11 inches