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);
    }
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);
    }
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 ) ; }
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"'
Joins an associative array into a string for use in an HTTP header .