Phphttp_build_query concatenation array

Source: Internet
Author: User
Http_build_query (PHP5) http_build_query & mdash; request string generated after URL-encode description stringhttp_build_query (array $ formdata [, string $ numeric_prefix]) use the given Association (or subscript) array to generate a URL-en

 

Http_build_query

(PHP 5)

Http_build_query-request string generated after URL-encode

Description: string http_build_query (array $ formdata [, string $ numeric_prefix])

Generate a URL-encode request string using the given correlated (or subscript) array. The formdata parameter can be an array or an object containing attributes. A formdata array can be a simple one-dimensional structure or an array composed of arrays (which can contain other arrays in turn ). If the numeric subscript is used in the base array and the numeric_prefix parameter is provided, the value of this parameter is used as the prefix of the numeric subscript element in the base array. This is to allow PHP or other CGI programs to obtain valid variable names when decoding data later.

 

1 Note:
2 Use arg_separator.output to separate parameters.

 

01 Example #1 http_build_query () Example
02
03 $ Data = array ('foo' => 'bar ',
04 'Baz' => 'boom ',
05 'Cow' => 'milk ',
06 'Php' => 'HyperText processor ');
07
08 Echo http_build_query ($ data); // foo = bar & baz = boom & cow = milk & php = hypertext + processor
09 ?>
10 Example #2 http_build_query () use the following element of a number
11
12 $ Data = array ('foo', 'bar', 'Baz', 'Boom ', 'cow' => 'milk ', 'php' => 'HyperText processor ');
13
14 Echo http_build_query ($ data );
15  
16  
17 Echo http_build_query ($ data, 'myvar _');
18  
19 ?>

 

Simply understand that the two functions parse_str are a url? After the parameters are converted to an array parse_str (url, arr) parse_url, a complete url is parsed into an array parse_url (string url) http_build_query, which is to convert an array to a url? The following parameter string will be automatically processed by urlencode string http_build_query (array formdata [, string numeric_prefix])

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.