private function getHeaders($str) {
    $str = explode(self::LE . self::LE, $str);
    $str = reset($str);
    $str = explode(self::LE, $str);
    $new = array();
    $s = 1;
    foreach ($str as $line) {
      $pos = strpos($line, ': ');
      if ($pos !== false) {
        $key = strtolower(substr($line, 0, $pos));
        if (!isset($new[$key])) {
          $new[$key] = preg_replace('/\s+/', ' ', trim(substr($line, $pos+1)));
        }
        else {
          $new[$key.'-'.$s] = preg_replace('/\s+/', ' ', trim(substr($line, $pos+1)));
          $s++;
        }
      }
      else {
        $new['status'] = $line; # HTTP/1.1 200 OK
      }
    }
    return $new;
  }
private function getHeaders($str) {
    $str = explode(self::LE . self::LE, $str);
    $str = reset($str);
    $str = explode(self::LE, $str);
    $new = array();
    $s = 1;
    foreach ($str as $line) {
      $pos = strpos($line, ': ');
      if ($pos !== false) {
        $key = strtolower(substr($line, 0, $pos));
        if (!isset($new[$key])) {
          $new[$key] = preg_replace('/\s+/', ' ', trim(substr($line, $pos+1)));
        }
        else {
          $new[$key.'-'.$s] = preg_replace('/\s+/', ' ', trim(substr($line, $pos+1)));
          $s++;
        }
      }
      else {
        $new['status'] = $line; # HTTP/1.1 200 OK
      }
    }
    return $new;
  }
private function getHeaders ( $ str ) { $ str = explode ( self :: LE . self :: LE , $ str ) ; $ str = reset ( $ str ) ; $ str = explode ( self :: LE , $ str ) ; $ new = array ( ) ; $ s = 1 ; foreach ( $ str as $ line ) { $ pos = strpos ( $ line , ': ' ) ; if ( $ pos !== false ) { $ key = strtolower ( substr ( $ line , 0 , $ pos ) ) ; if ( ! isset ( $ new [ $ key ] ) ) { $ new [ $ key ] = preg_replace ( '/\s+/' , ' ' , trim ( substr ( $ line , $ pos + 1 ) ) ) ; } else { $ new [ $ key . '-' . $ s ] = preg_replace ( '/\s+/' , ' ' , trim ( substr ( $ line , $ pos + 1 ) ) ) ; $ s ++ ; } } else { $ new [ 'status' ] = $ line ; # HTTP/1.1 200 OK } } return $ new ; }
Parses headers from string
@param  string $str
@return array
Parses headers from string