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

How to convert php url to array

藏色散人
藏色散人Original
2020-08-01 11:02:393026browse

php url to array method: first get the url string; then parse the query string into variables through the parse_str function, and store the variables into an array; finally print out the converted value through "var_dump" Just an array.

How to convert php url to array

Recommended: "PHP Video Tutorial"

Convert the string of URL with & into an array

For example:

$str = "title=我是小白&name=真的很白&text=但是决不放弃";
parse_str($str, $res);   //第一个参数为字符串,第二个参数为结果
var_dump($res);
exit;

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