Here’s a comma separated string function which uses the serial comma properly with a conjunction in a list. e.g. apple, berry, ice cream => apple, berry and ice cream. It’s essentially a natural language join:
public static function natural_language_join(array $list, $conjunction = 'and') { $last = array_pop($list); if ($list) { return implode(', ', $list) . ' ' . $conjunction . ' ' . $last; } return $last; }
You can customize the conjunction to any word you need.