Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How php converts the parameters of url into an array

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian for you to introduce in detail "php how to convert the parameters of url into an array", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "php how to convert the parameters of url into an array" can help you solve your doubts.

Conversion method: 1, use "mb_substr ($url,stripos ($url,") + 1) "to get the parameter part of url; 2, use" parse_str ("parameter part", $arr) "to parse the parameter into the variable and pass it into the specified array, the variable name is changed into key name, and the variable value is converted into key value.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php converts the parameters of url into an array

Implementation method:

Use stripos () to get the character "?" The position of

Use mb_substr () to intercept the string according to the obtained position to get the parameter part of the url

Use parse_str () to parse the parameter into a variable and pass it into the specified array

Key points: parse_str ()

The parse_str () function parses the query string into a variable.

The parse_str (string,array) parameter is required to describe string. Specifies the string to be parsed. Array is optional. Specifies the name of the array in which the variables are stored. This parameter indicates that the variable is stored in an array.

Implementation example:

As you can see, parse_str () parses the parameters one by one into variables and passes them into the array; and the variable name is changed to the key name, and the variable value to the key value.

Read this, the "php how to convert the parameters of url into an array" article has been introduced, want to master the knowledge of this article still need to practice and use to understand, if you want to know more about the article, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report