Helper::formatList PHP Method

formatList() public static method

Format a list of strings with comma separators and a final 'and'.
public static formatList ( array $items ) : string
$items array
return string
    public static function formatList(array $items)
    {
        switch (count($items)) {
            case 0:
                return '';
                break;
            case 1:
                return reset($items);
                break;
            default:
                $last = array_pop($items);
                return implode(', ', $items) . ' and ' . $last;
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Systemic diagnoses shortcode
  *
  * @return string
  */
 public function getSyd()
 {
     return strtolower(Helper::formatList(Helper::extractValues($this->getSystemicDiagnoses(), 'disorder.term')));
 }
All Usage Examples Of Helper::formatList