Skip to content

Instantly share code, notes, and snippets.

@guoxiangke
Created June 30, 2015 03:54
Show Gist options
  • Select an option

  • Save guoxiangke/2715e399c1e165a84de0 to your computer and use it in GitHub Desktop.

Select an option

Save guoxiangke/2715e399c1e165a84de0 to your computer and use it in GitHub Desktop.
//正则表达式获取URL参数 preg get URL parameter
//正则表达式获取URL参数 preg get URL parameter
//http://stackoverflow.com/questions/11706986/php-getting-url-variable-with-preg-match
$subject = "http://www.mysite.com?id=05&name=johnny";
$pattern = '/id=[0-9A-Za-z]*/'; //$pattern = '/id=[0-9]*/'; if it is only numeric.
preg_match($pattern, $subject, $matches);
print_r($matches);
@guoxiangke
Copy link
Author

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