Skip to content

Instantly share code, notes, and snippets.

@kayue
Created October 14, 2010 10:37
Show Gist options
  • Save kayue/625999 to your computer and use it in GitHub Desktop.
Save kayue/625999 to your computer and use it in GitHub Desktop.
<?
/**
* Give name to preg_match
*/
$haystack = '01 Jan 1970';
$pattern = '/(?<day>\d{1,2})\ (?<month>Jan|Feb)\ (?<year>19\d\d)/';
preg_match($pattern, $haystack, $matches);
print_r($matches);
// now there's $matches['day'], $matches['month'] ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment