function HeaderUtils::toString
Joins an associative array into a string for use in an HTTP header.
The key and value of each entry are joined with '=', and all entries are joined with the specified separator and an additional space (for readability). Values are quoted if necessary.
Example:
HeaderUtils::toString(['foo' => 'abc', 'bar' => true, 'baz' => 'a b c'], ',') // => 'foo=abc, bar, baz="a b c"'
3 calls to HeaderUtils::toString()
- AcceptHeaderItem::__toString in vendor/
symfony/ http-foundation/ AcceptHeaderItem.php - Returns header value's string representation.
- HeaderBag::getCacheControlHeader in vendor/
symfony/ http-foundation/ HeaderBag.php - HeaderUtils::makeDisposition in vendor/
symfony/ http-foundation/ HeaderUtils.php - Generates an HTTP Content-Disposition field-value.
File
-
vendor/
symfony/ http-foundation/ HeaderUtils.php, line 111
Class
- HeaderUtils
- HTTP header utility functions.
Namespace
Symfony\Component\HttpFoundationCode
public static function toString(array $assoc, string $separator) : string {
$parts = [];
foreach ($assoc as $name => $value) {
if (true === $value) {
$parts[] = $name;
}
else {
$parts[] = $name . '=' . self::quote($value);
}
}
return implode($separator . ' ', $parts);
}