oxfordList (function)

Last updated: Mon, Apr 17, 2023 1:13 pm
Return to Knowledgebase

Purpose

Takes an array of strings and an optional array of options as its parameters. It returns a string that is a grammatically correct list of the items in the array.

Location

users/helpers/us_helpers.php

Parameters

# Parameter Data Type Required Description
1 $data array Yes an array of strings representing the items in the list
2 $opts = [] array No an optional array of options. The only option currently supported is final, which is a string to use as the final conjunction in the list (e.g. "and" or "or").

Returns

Data Type Description of Returned Data
string A string that is a grammatically correct list of the items in the array.

Further Documentation:

The oxfordList function takes an array of strings and an optional array of options as its parameters. It returns a string that is a grammatically correct list of the items in the array.

Example usage:

$myArray = array("apple", "banana", "orange");
$options = array("final" => "or");
echo oxfordList($myArray, $options); // Output: "apple, banana, or orange"