Menu Samaritan's Purse

HTTP_BUILD_QUERY

Generate URL-encoded query string

SYNTAX

http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] ) : string

PARAMETERS

query_data

May be an array or object containing properties. If query_data is an array, it may be a simple one-dimensional structure, or an array of arrays (which in turn may contain other arrays). If query_data is an object, then only public properties will be incorporated into the result.

numeric_prefix

If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only. This is meant to allow for legal variable names when the data is decoded by PHP or another CGI application later on.

arg_separator

arg_separator.output is used to separate arguments but may be overridden by specifying this parameter.

enc_type

By default, PHP_QUERY_RFC1738. If enc_type is PHP_QUERY_RFC1738, then encoding is performed per RFC 1738 and the application/x-www-form-urlencoded media type, which implies that spaces are encoded as plus (+) signs. If enc_type is PHP_QUERY_RFC3986, then encoding is performed according to RFC 3986, and spaces will be percent encoded (%20).

RETURN

Returns a URL-encoded string.

EXAMPLES

QUERY_DATA | ARRAY | INDEXED

0=dog&1=cat&2=mama+llama

QUERY_DATA | ARRAY | ASSOCIATIVE

a=dog&b=cat&c=mama+llama

QUERY_DATA | ARRAY | MULTIDIMENSIONAL

a%5B0%5D=dog&a%5B1%5D%5B0%5D=0&a%5B1%5D%5B1%5D=1&b=cat&c%5B0%5D=mama+llama&c%5B1%5D%5B0%5D=0&c%5B1%5D%5B1%5D=1&c%5B1%5D%5B2%5D%5B0%5D=0&c%5B1%5D%5B2%5D%5B1%5D=1

QUERY_DATA | OBJECT

pub=publicparent&pub2%5Bpub%5D=publicchild

NUMERIC_PREFIX

prefix0=dog&prefix1=cat&prefix2=mama+llama

ARG_SEPARATOR

0=dog#1=cat#2=mama+llama

ENC_TYPE

0=dog&1=cat&2=mama%20llama

PHP