PHP Http_build_query Implementation Tutorial
Http_build_query
(in PHP 5)
Http_build_query-Generate URL-encoded query string
Describe
String Http_build_query (array $ formdata [, String $ numeric_prefix [, String $ arg_separator]])
Generates a URL-encoded query string from a Lenovo (or indexed) array.
Parameters
Formdata
may be an array or an object containing an attribute.
The form of an array may be a simple one-dimensional structure, or an array of arrays (who may also contain other arrays).
Numeric_prefix
If the number indicator is used for the base display and provides this parameter, this will be the basis of the prepended's digital index content only.
This is the law allowed for variable names when data is decoded on PHP or other CGI applications.
Arg_separator
Arg_separator.output is used for separate arguments, unless this parameter is specified and then used.
return value
Returns a URL-encoded string.
Modify
Release Notes
5.1.2 Arg_separator parameter supplement.
5.1.3 is escaped inside the square brackets.
Instance
For example # 1 easy to use Http_build_query ()
$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
Echo http_build_query ($data, ', ' & '); Foo=bar&baz=boom&cow=milk&php=hypertext+processor
?>
Example #2 http_build_query () with numerically index elements.
$data = Array (' foo ', ' Bar ', ' baz ', ' boom ', ' cow ' = ' milk ', ' php ' = ' hypertext processor ');
echo Http_build_query ($data). "N";
Echo http_build_query ($data, ' myvar_ ');
?>
The above example would output:
0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor
Myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor
Example #3 Http_build_query () with complex arrays
$data = Array (' User ' =>array (' name ' = ' Bob Smith '),
' Age ' =>47,
' Sex ' = ' M ',
' DOB ' = ' 5/12/1956 '),
' Pastimes ' =>array (' Golf ', ' opera ', ' Poker ', ' rap '),
' Children ' =>array (' Bobby ' =>array (' age ' =>12,
' Sex ' = ' M '),
' Sally ' =>array (' age ' =>8,
' Sex ' = ' F '),
' CEO ');
Echo http_build_query ($data, ' flags_ ');
http://www.bkjia.com/PHPjc/445454.html www.bkjia.com true http://www.bkjia.com/PHPjc/445454.html techarticle php http_build_query Implementation Tutorial Http_build_query (PHP 5) http_build_query-Generate URL-encoded query string description string Http_build_query (array $ formda Ta [, String ...