Phphttp_build_query implementation tutorial. Phphttp_build_query implementation tutorial http_build_query (in PHP5) http_build_query-generate URL encoding query string description string http_build_query (array $ formdata [, string php http_build_query implementation tutorial
Http_build_query
(In PHP 5)
Http_build_query-generate URL encoding query string
Description
String http_build_query (array $ formdata [, string $ numeric_prefix [, string $ arg_separator])
Generate a URL encoded query string provided from the Lenovo (or index) array.
Parameters
Formdata
An array or object may contain attributes.
The array form may be a simple one-dimensional structure, or an array (which may also contain other arrays ).
Numeric_prefix
If the numeric indicator is used for basic display and provides this parameter, this will be the basic display of the prepended numeric index content only.
This is a variable name permitted by law. data decoding is performed in 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
Version description
5.1.2 supplement the arg_separator parameter.
5.1.3 escape characters in square brackets.
Instance
For example, #1 simple use of 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 will 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' => '2017/123 '),
'Pastimes' => array ('golf', 'Opera ', 'poker', 'rap '),
'Children '=> array ('Bob' => array ('age' => 12,
'Sex '=>'m '),
'Sally '=> array ('age' => 8,
'Sex' => 'F ')),
'CEOs ');
Echo http_build_query ($ data, 'flags _');
Http://www.bkjia.com/PHPjc/445454.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445454.htmlTechArticlephp http_build_query implementation tutorial http_build_query (PHP 5) http_build_query-generate URL encoding query string description string http_build_query (array $ formdata [, string...