Skip to content

Instantly share code, notes, and snippets.

@erochest
Forked from jeremyboggs/multiple_creators.php
Created July 31, 2012 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erochest/3219134 to your computer and use it in GitHub Desktop.
Save erochest/3219134 to your computer and use it in GitHub Desktop.
Changes how creators are listed depending on their numbers
<?php
/**
* One Creator: "Jane Doe"
* Two creators: "Jane Doe and John Doe"
* Three creators: "Jane Doe, John Doe, and Jim Doe"
* Four or more: "Jane Doe et al."
*/
if ($creators) {
switch (count($creators) {
case 1:
$cite = $creators[0];
break;
case 2:
$cite = "{$creators[0]} and {$creators[1]}";
break;
case 3:
$cite = "{$creators[0]}, {$creators[1]}, and {$creators[2]}";
break;
default:
$cite = "{$creators[0]}, et al.";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment