+

PHP Http_build_query () function

Syntax:
string http_build_query ($query_data, $numeric_prefix, $arg_separator, $enc_type = PHP_QUERY_RFC1738)
Parameters:This function takes four parameters as above and described below:
  • $query_data:This parameter contains an array or object containing properties below:
    • This can be a one-dimensional array or a multi-dimensional array.
    • If $query_data is an object, then only the public property will be included in the result.
    • $numeric_prefix:this parameter is used if numeric indices are used in the base array, it will be added to the numeric index only for elements in the base array.
    • $arg_separator:It is used to separate arguments, but can be overridden by specifying this parameter.
    • $enc_type:its default value - PHP_QUERY_RFC1738.
    Returned values:returns a URL encoded string.The following programs illustrate the http_build_query() function in PHP:Program 1: $info = array ( `sudo` = > `placement` , `CPP` = > ` course` , `FORK` = > `C` , ); echo http_build_query ( $info ). "#" ; echo http_build_query ( $info , `` , `& amp;` );  
    ?>
    Exit:
    sudo = placement & amp ; CPP = course & amp; FORK = C # sudo = placement & amp; CPP = course & amp; FORK = C
    Program 2: $info = array ( `engineer` , `gfg` = > ` sudo` , `placement` = > ` hypertext processor ` ); echo http_build_query ( $info ). "$" ; echo http_build_query ( $info , `myvar_` ); ?> Exit:
    0 = engineer & amp ; gfg = sudo & amp; placement = hypertext + processor $myvar_0 = engineer & amp; gfg = sudo & amp; placement = hypertext + processor
    Link:http://docs.php.net/manual/da/function.http-build-query.php
Get Solution for free from DataCamp guru