A function to take a list of terms and return them in an English phrase with proper punctuation 'red, black, and white' or 'red and black'.

1.2.0 2020-03-26 13:04 UTC

This package is auto-updated.

Last update: 2024-04-25 03:01:48 UTC



"We talked with his teachers, Oprah, and Barack Obama" not "We talked with his teachers, Oprah and Barack Obama".

"The dog ate carrots, grapes, and peanut butter and jelly sandwiches" not "The dog ate carrots, grapes and peanut butter and jelly sandwiches."

Usage of this library

Turn an array of strings into a natural-language list:

use Agaric\OxfordComma;

$array = ["State Fair", "South Pacific", "The King and I"];
$text = OxfordComma\oxford_comma_list($array); // State Fair, South Pacific, and The King and I