Skip to content

Instantly share code, notes, and snippets.

@huntlyc
Forked from JeffreyWay/gist:2889230
Created June 7, 2012 16:16
Show Gist options
  • Save huntlyc/2889818 to your computer and use it in GitHub Desktop.
Save huntlyc/2889818 to your computer and use it in GitHub Desktop.
Simple PHP Quiz
// Fun little quiz
Assuming this string: "January 5th, 2012"
In the shortest amount of code possible, place:
- 'January' within a $month variable
- '5th' within a $day variable
- '2012' within a $year variable.
See if you can accomplish this with one line of code. (And no snarky $month = 'January' answers.
Assume that the format always stays the same, but month, day, and year values can change with each referesh.
@huntlyc
Copy link
Author

huntlyc commented Jun 7, 2012

list($month, $day, $year) = preg_split ("#,?\s+#", "January 5th, 2012");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment