wpcf7_build_query

From _http_build_query in wp-includes/functions.php.

Description

wpcf7_build_query( $args, (string) $key = '' ); 

Parameters (2)

0. $args
The args.
1. $key — Optional. (string) => ''
The key.

Usage

  1. if ( !function_exists( 'wpcf7_build_query' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/includes/functions.php'; 
  3.  
  4. // The args. 
  5. $args = null; 
  6.  
  7. // The key. 
  8. $key = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpcf7_build_query($args, $key); 
  12.  

Defined (1)

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

/includes/functions.php  
  1. function wpcf7_build_query( $args, $key = '' ) { 
  2. $sep = '&'; 
  3. $ret = array(); 
  4.  
  5. foreach ( (array) $args as $k => $v ) { 
  6. $k = urlencode( $k ); 
  7.  
  8. if ( ! empty( $key ) ) { 
  9. $k = $key . '%5B' . $k . '%5D'; 
  10.  
  11. if ( null === $v ) { 
  12. continue; 
  13. } elseif ( false === $v ) { 
  14. $v = '0'; 
  15.  
  16. if ( is_array( $v ) || is_object( $v ) ) { 
  17. array_push( $ret, wpcf7_build_query( $v, $k ) ); 
  18. } else { 
  19. array_push( $ret, $k . '=' . urlencode( $v ) ); 
  20.  
  21. return implode( $sep, $ret );