WP_CLI\Iterators

CSV::next()publicWP-CLI 1.0

Method of the class: CSV{}

No Hooks.

Return

null. Nothing (null).

Usage

$CSV = new CSV();
$CSV->next();

CSV::next() code WP-CLI 2.8.0-alpha

public function next() {
	$this->current_element = false;

	while ( true ) {
		$str = fgets( $this->file_pointer );

		if ( false === $str ) {
			break;
		}

		$row = str_getcsv( $str, $this->delimiter );

		$element = [];
		foreach ( $this->columns as $i => $key ) {
			if ( isset( $row[ $i ] ) ) {
				$element[ $key ] = $row[ $i ];
			}
		}

		if ( ! empty( $element ) ) {
			$this->current_element = $element;
			$this->current_index++;

			break;
		}
	}
}