Skip to content

Instantly share code, notes, and snippets.

@blar
Created August 31, 2012 22:11
Show Gist options
  • Select an option

  • Save blar/3559854 to your computer and use it in GitHub Desktop.

Select an option

Save blar/3559854 to your computer and use it in GitHub Desktop.
<?php
preg_match_all('<(?P<key>\w+)\:(?P<value>\d+)>', 'foo:23,bar:42', $matches);
var_dump($matches);
array(5) {
[0]=>
array(2) {
[0]=>
string(6) "foo:23"
[1]=>
string(6) "bar:42"
}
["key"]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
}
[1]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
}
["value"]=>
array(2) {
[0]=>
string(2) "23"
[1]=>
string(2) "42"
}
[2]=>
array(2) {
[0]=>
string(2) "23"
[1]=>
string(2) "42"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment