build_query

Build URL query based on an associative and, or indexed array.

Description

(string) build_query( (array) $data ); 

This is a convenient function for easily building url queries. It sets the separator to & and uses _http_build_query() function.

Returns (string)

URL-encoded string.

Parameters (1)

0. $data (array)
URL-encode key/value pairs.

Usage

  1. if ( !function_exists( 'build_query' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // URL-encode key/value pairs. 
  5. $data = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = build_query($data); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function build_query( $data ) { 
  2. return _http_build_query( $data, null, '&', '', false );