What is the function http_build_query used for in PHP?

The function http_build_query in PHP is used to build a query string from an array of data. This function takes an associative array as input and returns a URL-encoded string with key-value pairs separated by '&'. It is commonly used when constructing URLs for HTTP requests or when working with form data.

```php
$data = array(
    'name' => 'John Doe',
    'age' => 30,
    'city' => 'New York'
);

$queryString = http_build_query($data);

echo $queryString;
```

This code snippet will output: `name=John+Doe&age=30&city=New+York`