Ergo\Http\HeaderCollection::toArray PHP Method

toArray() public method

Returns an array of the string versions of headers
public toArray ( $crlf = true ) : array
return array
    function toArray($crlf = true)
    {
        $headers = array();
        foreach ($this->_headers as $header) {
            $string = $header->__toString();
            $headers[] = $crlf ? $string : rtrim($string);
        }
        return $headers;
    }

Usage Example

Example #1
0
 public function testSimpleUsage()
 {
     $collection = new Http\HeaderCollection();
     $collection->add('Content-Length: 9');
     $this->assertEquals($collection->values('Content-Length'), array('9'));
     $this->assertEquals($collection->value('Content-Length'), '9');
     $this->assertEquals($collection->toArray(false), array('Content-Length: 9'));
 }