Requests::flatten( WpOrgRequestsiterable $dictionary ): array

In this article

Convert a key => value array to a ‘key: value’ array for headers

Parameters

$dictionaryWpOrgRequestsiterablerequired
Dictionary of header values

Return

array List of headers

Source

public static function flatten($dictionary) {
	if (InputValidator::is_iterable($dictionary) === false) {
		throw InvalidArgument::create(1, '$dictionary', 'iterable', gettype($dictionary));
	}

	$return = [];
	foreach ($dictionary as $key => $value) {
		$return[] = sprintf('%s: %s', $key, $value);
	}

	return $return;
}

User Contributed Notes

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