function fp_http_build_query

7.x misc.inc fp_http_build_query(array $data, $parent = '')

This function is borrowed from Backdrop version 1.x. We use it to convert the $data (which is in the form of an assoc array of keys and values) into an HTTP query string.

Parameters

array $data:

string $parent:

Return value

string

2 calls to fp_http_build_query()
fp_http_request in includes/misc.inc
Send a request through the Internet and return the result as an object.
misc.inc in includes/misc.inc
This file contains misc functions for FlightPath

File

includes/misc.inc, line 790
This file contains misc functions for FlightPath

Code

function fp_http_build_query(array $data, $parent = '') {
  $params = array();

  foreach ($data as $key => $value) {
    $key = $parent ? $parent . rawurlencode('[' . $key . ']') : rawurlencode($key);

    // For better readability of paths in query strings, we decode slashes.
    $key = str_replace('%2F', '/', $key);

    // Recurse into children.
    if (is_array($value)) {
      $params [] = fp_http_build_query($value, $key);
    }
    // If a query parameter value is NULL, only append its key.
    elseif (!isset($value)) {
      $params [] = $key;
    }
    else {
      // For better readability of paths in query strings, we decode slashes.
      $params [] = $key . '=' . str_replace('%2F', '/', rawurlencode($value));
    }
  }

  return implode('&', $params);
}