PHP http_build_query Stitching Array
?
Http_build_query
(PHP 5)
http_build_query? request string after generating Url-encode
Description
string?
Http_build_query? (? array? $formdata ? [,? string? $numeric _prefix ?] )
Generates a Url-encode request string using the given array of associations (or subscripts). Parameters? formdata? can be an array or an object that contains properties. One? formdata? An array can be a simple one-dimensional structure or an array of arrays (which in turn can contain other arrays). What if a numeric subscript is used in the underlying array? numeric_prefixparameter, this parameter value will be prefixed with the number subscript element in the underlying array. This is to get a valid variable name when PHP or other CGI programs decode the data later.
Note:
Use the arg_separator.output? to separate the parameters.
Example #1? http_build_query ()? Using the 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 the element with a number subscript
$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 to convert a URL into an array after the argument
Array Parse_str (Url,arr)
Parse_url is to parse a full URL into an array
Array parse_url (string url)
Http_build_query is the conversion of an array into a URL, followed by a string of arguments that are automatically urlencode processed
String Http_build_query (Array formdata [, String Numeric_prefix])
Add subscript to the array without specifying a key or a key as a number