Home >Backend Development >PHP Problem >How to convert php url to array

How to convert php url to array

藏色散人
藏色散人Original
2020-08-26 09:21:354776browse

How to convert php url to an array: First create a PHP sample file; then define a url parameter string; finally use the "parse_str($str, $arr);" method to convert the url to an array. .

How to convert php url to array

Recommended: "PHP Video Tutorial"

parse_str()—Convert the url parameter string into an array

Convert url parameter string into array

$str = 'a=1&b=2&c=3';
parse_str($str, $arr);
var_dump($arr);
//输出 
array (size=3)
  'a' =>  '1' (length=1)
  'b' =>  '2' (length=1)
  'c' =>  '3' (length=1)

The above is the detailed content of How to convert php url to array. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn