Skip to main content
Joachim's blog

Main navigation

  • Home
  • About
  • Hire me

Breadcrumb

  1. Home

text

By joachim, Wed, 30/06/2010 - 15:59

The Oxford Comma

Here's a little function I wrote today because I needed to be able to turn a list of between one and three items into a string like 'apples, oranges, and pears', 'apples and pears', or just 'stairs'.

I figured I might as well handle everything in one place, and throw in the option to have an 'or' instead of an 'and'. There may be occasions you don't want the Oxford comma, but I can't think of any.


/**

Tags

  • drupal
  • php
  • theming
  • drupal planet
  • text
text

Frequent tags

  • Drupal Code Builder (9)
  • module builder (7)
  • git (7)
  • 6.x (5)
  • drupal commerce (4)
  • tests (3)
  • Field API (3)
  • patching (3)
  • Rector (3)
  • Composer (3)
  • Drush (3)
  • contributing code (3)
  • development (3)
  • Entity API (3)
  • deprecation (2)
  • multisite (2)
  • core (2)
  • issue queue (2)
  • Drupal core (2)
  • roadmap (2)
  • 7.x (2)
  • modules (2)
  • developer tools (2)
  • wtf (2)
  • contrib module (2)
  • maintaining projects (2)
  • code style (2)
  • drupal.org (2)
  • debugging (2)
Powered by Drupal