lib/ObjectSerializer.php
public function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti=false)
    {
        if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) {
            // http_build_query() almost does the job for us. We just
            // need to fix the result of multidimensional arrays.
            return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&'));
        }
        switch ($collectionFormat) {
            case 'pipes':
                return implode('|', $collection);

            case 'tsv':
                return implode("\t", $collection);

            case 'ssv':
                return implode(' ', $collection);

            case 'csv':
                // Deliberate fall through. CSV is default format.
            default:
                return implode(',', $collection);
        }
    }
public function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti=false)
    {
        if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) {
            // http_build_query() almost does the job for us. We just
            // need to fix the result of multidimensional arrays.
            return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&'));
        }
        switch ($collectionFormat) {
            case 'pipes':
                return implode('|', $collection);

            case 'tsv':
                return implode("\t", $collection);

            case 'ssv':
                return implode(' ', $collection);

            case 'csv':
                // Deliberate fall through. CSV is default format.
            default:
                return implode(',', $collection);
        }
    }
public function serializeCollection ( array $ collection , $ collectionFormat , $ allowCollectionFormatMulti = false ) { if ( $ allowCollectionFormatMulti && ( 'multi' === $ collectionFormat ) ) { // http_build_query() almost does the job for us. We just // need to fix the result of multidimensional arrays. return preg_replace ( '/%5B[0-9]+%5D=/' , '=' , http_build_query ( $ collection , '' , '&' ) ) ; } switch ( $ collectionFormat ) { case 'pipes' : return implode ( '|' , $ collection ) ; case 'tsv' : return implode ( "\t" , $ collection ) ; case 'ssv' : return implode ( ' ' , $ collection ) ; case 'csv' : // Deliberate fall through. CSV is default format. default : return implode ( ',' , $ collection ) ; } }
Serialize an array to a string.

@param array  $collection       collection to serialize to a string
@param string $collectionFormat the format use for serialization (csv,
ssv, tsv, pipes, multi)

@return string
Serialize an array to a string .