Home > Article > Backend Development > PHP parses url to get parameter values in url
This article will introduce you to how PHP parses the url and gets the parameters in the url and how to get the url parameters. The code in this article is simple and easy to understand. Friends who are interested can take a look.
The code is as follows
$url = 'http://www.baidu.com/index.php? m=content&c=index&a=lists&catid=6&area=0&author=0&h=0®ion=0&s=1&page=1'; parse_str(parse_url($url)[query],$query_arr); var_dump($query_arr);
Result
array (size=10) 'm' => string 'content' (length=7) 'c' => string 'index' (length=5) 'a' => string 'lists' (length=5) 'catid' => string '6' (length=1) 'area' => string '0' (length=1) 'author' => string '0' (length=1) 'h' => string '0' (length=1) 'region' => string '0' (length=1) 's' => string '1' (length=1) 'page' => string '1' (length=1)
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of PHP parses url to get parameter values in url. For more information, please follow other related articles on the PHP Chinese website!