Last active
February 4, 2018 18:58
-
-
Save kobus1998/29afda17d0d0393ad2f15ddb8227272c to your computer and use it in GitHub Desktop.
function capture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$regex = "(?<function>(?:int)\s*\w+\s*\((?:(?:int)\s*\w+\s*\,\s*){0,}+(?:int)\s*\w+\s*\)\s*\{\s*.*\s*\})"; | |
$str = " | |
int count(int i, int a) | |
{ | |
return i++; | |
} | |
"; | |
preg_match("/$regex/", $str, $matches, PREG_OFFSET_CAPTURE, 0); | |
// Print the entire match result | |
print_r($matches); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment