php/WP_CLI/Formatter.php
private function show_multiple_fields( $data, $format, $ascii_pre_colorized = false ) {

		$true_fields = array();
		foreach ( $this->args['fields'] as $field ) {
			$true_fields[] = $this->find_item_key( $data, $field );
		}

		foreach ( $data as $key => $value ) {
			if ( ! in_array( $key, $true_fields, true ) ) {
				if ( is_array( $data ) ) {
					unset( $data[ $key ] );
				} elseif ( is_object( $data ) ) {
					unset( $data->$key );
				}
			}
		}

		switch ( $format ) {

			case 'table':
			case 'csv':
				$rows   = $this->assoc_array_to_rows( $data );
				$fields = array( 'Field', 'Value' );
				if ( 'table' === $format ) {
					self::show_table( $rows, $fields, $ascii_pre_colorized );
				} elseif ( 'csv' === $format ) {
					\WP_CLI\Utils\write_csv( STDOUT, $rows, $fields );
				}
				break;

			case 'yaml':
			case 'json':
				\WP_CLI::print_value(
					$data,
					array(
						'format' => $format,
					)
				);
				break;

			default:
				\WP_CLI::error( 'Invalid format: ' . $format );
				break;

		}

	}
private function show_multiple_fields( $data, $format, $ascii_pre_colorized = false ) {

		$true_fields = array();
		foreach ( $this->args['fields'] as $field ) {
			$true_fields[] = $this->find_item_key( $data, $field );
		}

		foreach ( $data as $key => $value ) {
			if ( ! in_array( $key, $true_fields, true ) ) {
				if ( is_array( $data ) ) {
					unset( $data[ $key ] );
				} elseif ( is_object( $data ) ) {
					unset( $data->$key );
				}
			}
		}

		switch ( $format ) {

			case 'table':
			case 'csv':
				$rows   = $this->assoc_array_to_rows( $data );
				$fields = array( 'Field', 'Value' );
				if ( 'table' === $format ) {
					self::show_table( $rows, $fields, $ascii_pre_colorized );
				} elseif ( 'csv' === $format ) {
					\WP_CLI\Utils\write_csv( STDOUT, $rows, $fields );
				}
				break;

			case 'yaml':
			case 'json':
				\WP_CLI::print_value(
					$data,
					array(
						'format' => $format,
					)
				);
				break;

			default:
				\WP_CLI::error( 'Invalid format: ' . $format );
				break;

		}

	}
private function show_multiple_fields ( $ data , $ format , $ ascii_pre_colorized = false ) { $ true_fields = array ( ) ; foreach ( $ this -> args [ 'fields' ] as $ field ) { $ true_fields [ ] = $ this -> find_item_key ( $ data , $ field ) ; } foreach ( $ data as $ key => $ value ) { if ( ! in_array ( $ key , $ true_fields , true ) ) { if ( is_array ( $ data ) ) { unset ( $ data [ $ key ] ) ; } elseif ( is_object ( $ data ) ) { unset ( $ data -> $ key ) ; } } } switch ( $ format ) { case 'table' : case 'csv' : $ rows = $ this -> assoc_array_to_rows ( $ data ) ; $ fields = array ( 'Field' , 'Value' ) ; if ( 'table' === $ format ) { self :: show_table ( $ rows , $ fields , $ ascii_pre_colorized ) ; } elseif ( 'csv' === $ format ) { \ WP_CLI \ Utils \ write_csv ( STDOUT , $ rows , $ fields ) ; } break ; case 'yaml' : case 'json' : \ WP_CLI :: print_value ( $ data , array ( 'format' => $ format , ) ) ; break ; default : \ WP_CLI :: error ( 'Invalid format: ' . $ format ) ; break ; } }
Show multiple fields of an object.

@param object|array $data                Data to display
@param string       $format              Format to display the data in
@param bool|array   $ascii_pre_colorized Optional. A boolean or an array of booleans to pass to `show_table()` if the item in the table is pre-colorized. Default false.
Show multiple fields of an object .