PHP Development Tips (ix) How to get the various parameters in-url

Source: Internet
Author: User
In the normal development of Web sites, we have to deal with URLs, we can access specific addresses through a URL, we can pass the URL we need to test parameters, so how to get the parameters in the URL becomes important. This blog post will be how to get the parameters in the URL, this is just a function method, by passing the complete URL address string to get the parameters, the following is the code:

<?php    /**  * =======================================  * Created by Zhihua_w.  * Author:zhihua_w  * DATE:2017/1/3 0009  * Time: Morning 11:03  * project:php Development Tips  * Power: Get each parameter in the URL  * = ====================================== */    /**  * Get each parameter in the URL  * similar to PAY_CODE=ALIPAY&BANK_ Code=icbc-debit  * @param type $str  * @return Type  *  /function Parse_url_param ($str)  {      $data = Array ();      $parameter = Explode (' & ', End (explode ('? ', $str)));      foreach ($parameter as $val) {          $tmp = explode (' = ', $val);          $data [$tmp [0]] = $tmp [1];      }      return $data;  }    ? >
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.