fuel/fuel/core/classes/request/curl.php
protected function encode(array $input)
	{
		// Detect the request content type, default to 'text/plain'
		$content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : $this->response_info('content_type', 'text/plain');

		// Get the correct format for the current content type
		$format = \Arr::key_exists(static::$auto_detect_formats, $content_type) ? static::$auto_detect_formats[$content_type] : null;

		switch($format)
		{
			// Format as XML
			case 'xml':
					/**
					 * If the input array has one item in the top level
					 * then use that item as the root XML element.
					 */
					if(count($input) === 1)
					{
						$base_node = key($input);
						return \Format::forge($input[$base_node])->to_xml(null, null, $base_node);
					}
					else
					{
						return \Format::forge($input)->to_xml();
					}
				break;

			// Format as JSON
			case 'json':
					return \Format::forge($input)->to_json();
				break;

			// Format as PHP Serialized Array
			case 'serialize':
					return \Format::forge($input)->to_serialize();
				break;

			// Format as PHP Array
			case 'php':
					return \Format::forge($input)->to_php();
				break;

			// Format as CSV
			case 'csv':
					return \Format::forge($input)->to_csv();
				break;

			// Format as Query String
			default:
					return http_build_query($input, null, '&');
				break;
		}
	}
protected function encode(array $input)
	{
		// Detect the request content type, default to 'text/plain'
		$content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : $this->response_info('content_type', 'text/plain');

		// Get the correct format for the current content type
		$format = \Arr::key_exists(static::$auto_detect_formats, $content_type) ? static::$auto_detect_formats[$content_type] : null;

		switch($format)
		{
			// Format as XML
			case 'xml':
					/**
					 * If the input array has one item in the top level
					 * then use that item as the root XML element.
					 */
					if(count($input) === 1)
					{
						$base_node = key($input);
						return \Format::forge($input[$base_node])->to_xml(null, null, $base_node);
					}
					else
					{
						return \Format::forge($input)->to_xml();
					}
				break;

			// Format as JSON
			case 'json':
					return \Format::forge($input)->to_json();
				break;

			// Format as PHP Serialized Array
			case 'serialize':
					return \Format::forge($input)->to_serialize();
				break;

			// Format as PHP Array
			case 'php':
					return \Format::forge($input)->to_php();
				break;

			// Format as CSV
			case 'csv':
					return \Format::forge($input)->to_csv();
				break;

			// Format as Query String
			default:
					return http_build_query($input, null, '&');
				break;
		}
	}
protected function encode ( array $ input ) { // Detect the request content type, default to 'text/plain' $ content_type = isset ( $ this -> headers [ 'Content-Type' ] ) ? $ this -> headers [ 'Content-Type' ] : $ this -> response_info ( 'content_type' , 'text/plain' ) ; // Get the correct format for the current content type $ format = \ Arr :: key_exists ( static :: $ auto_detect_formats , $ content_type ) ? static :: $ auto_detect_formats [ $ content_type ] : null ; switch ( $ format ) { // Format as XML case 'xml' : /**
					 * If the input array has one item in the top level
					 * then use that item as the root XML element.
					 */ if ( count ( $ input ) === 1 ) { $ base_node = key ( $ input ) ; return \ Format :: forge ( $ input [ $ base_node ] ) -> to_xml ( null , null , $ base_node ) ; } else { return \ Format :: forge ( $ input ) -> to_xml ( ) ; } break ; // Format as JSON case 'json' : return \ Format :: forge ( $ input ) -> to_json ( ) ; break ; // Format as PHP Serialized Array case 'serialize' : return \ Format :: forge ( $ input ) -> to_serialize ( ) ; break ; // Format as PHP Array case 'php' : return \ Format :: forge ( $ input ) -> to_php ( ) ; break ; // Format as CSV case 'csv' : return \ Format :: forge ( $ input ) -> to_csv ( ) ; break ; // Format as Query String default : return http_build_query ( $ input , null , '&' ) ; break ; } }
Function to encode input array depending on the content type

@param   array $input
@return  mixed encoded output
Function to encode input array depending on the content type