How can http_build_query be utilized to create a URL parameter string in PHP?

When creating a URL parameter string in PHP, the `http_build_query` function can be utilized to easily encode an array into a URL-encoded query string. This function takes an associative array as input and returns a string in the format key1=value1&key2=value2. This is useful for constructing URLs with parameters dynamically.

// Example of using http_build_query to create a URL parameter string
$params = array(
    'name' => 'John Doe',
    'age' => 30,
    'city' => 'New York'
);

$url = 'http://example.com/api?' . http_build_query($params);

echo $url;