Phphttp_build_query patchwork array

Source: Internet
Author: User
Phphttp_build_query concatenate an array? Http_build_query (PHP5) http_build_query? ―? Description of the request string after URL-encode is generated: string? Http_build_query? (? Array? $ Formdata? [,? String? $ Numeric_prefix?]) Php http_build_query concatenation array

?

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. Parameter?Formdata? It can be an array or an object containing attributes. One?Formdata? An 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 basic array?Numeric_prefix? Parameter. 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.

Note:

Use? Arg_separator.output? To separate parameters.

Example #1?Http_build_query ()? Example

$data?=?array('foo'=>'bar',
??????????????'baz'=>'boom',
??????????????'cow'=>'milk',
??????????????'php'=>'hypertext?processor');
??????????????
echo?http_build_query($data);?//?foo=bar&baz=boom&cow=milk&php=hypertext+processor
?>

Example #2?Http_build_query ()? Use a number base element

$data?=?array('foo',?'bar',?'baz',?'boom',?'cow'?=>?'milk',?'php'?=>'hypertext?processor');
??????????????
echo?http_build_query($data);

?
echo?http_build_query($data,?'myvar_');

?>


========================================================== ========================================================== ========


A simple understanding of these two functions

Parse_str is a url? The following parameters are converted into an array.

Array parse_str (url, arr)


Parse_url parses a complete url into an array.

Array parse_url (string url)


Http_build_query is to convert an array into a url? The parameter string that follows will be automatically processed by urlencode.

String http_build_query (array formdata [, string numeric_prefix])

No key or subscript is specified for the array.

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.