Fsockopen::format_get( array $url_parts, array|object $data ): string

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Format a URL given GET data

Parameters

$url_partsarrayrequired
Array of URL parts as received from https://www.php.net/parse_url
$dataarray|objectrequired
Data to build query using, see https://www.php.net/http_build_query

Return

string URL with data

Source


/**
 * Format a URL given GET data
 *
 * @param array        $url_parts Array of URL parts as received from https://www.php.net/parse_url
 * @param array|object $data Data to build query using, see https://www.php.net/http_build_query
 * @return string URL with data
 */
private static function format_get($url_parts, $data) {
	if (!empty($data)) {
		if (empty($url_parts['query'])) {
			$url_parts['query'] = '';
		}

		$url_parts['query'] .= '&' . http_build_query($data, '', '&');
		$url_parts['query']  = trim($url_parts['query'], '&');
	}

	if (isset($url_parts['path'])) {
		if (isset($url_parts['query'])) {
			$get = $url_parts['path'] . '?' . $url_parts['query'];
		} else {

User Contributed Notes

You must log in before being able to contribute a note or feedback.