Habari\Format::and_list PHP Метод

and_list() публичный статический Метод

function and_list Turns an array of strings into a friendly delimited string separated by commas and an "and"
public static and_list ( array $array, string $between = ', ', string $between_last = null )
$array array An array of strings
$between string Text to put between each element
$between_last string Text to put between the next-to-last element and the last element
    public static function and_list($array, $between = ', ', $between_last = null)
    {
        if (!is_array($array)) {
            $array = array($array);
        }
        if ($between_last === null) {
            // @locale The default string used between the last two items in a series (one, two, three *and* four).
            $between_last = _t(' and ');
        }
        $last = array_pop($array);
        $out = implode($between, $array);
        $out .= $out == '' ? $last : $between_last . $last;
        return $out;
    }