src/Csv.php
public function add($row) {
	$this->changesMade = true;
	$rowColumns = $row;
	$rowAssociative = $row;

	$this->lock();

	if($this->isAssoc($row)) {
		if(!$this->headers) {
			$this->headers = array_keys($row);
			$this->file->fputcsv($this->headers);
		}
		$rowColumns = $this->toIndexed($row, true);
	}
	else {
		$rowAssociative = $this->toAssociative($row);
	}

	if(!$this->headers) {
		throw new HeadersNotSetException();
	}

	$rowColumns = $this->fillMissing($rowColumns);

	$this->file->fseek(0, SEEK_END);
	$this->file->fputcsv($rowColumns);
	$this->file->fflush();

	$this->file->flock(LOCK_UN);
	return $rowAssociative;
}
public function add($row) {
	$this->changesMade = true;
	$rowColumns = $row;
	$rowAssociative = $row;

	$this->lock();

	if($this->isAssoc($row)) {
		if(!$this->headers) {
			$this->headers = array_keys($row);
			$this->file->fputcsv($this->headers);
		}
		$rowColumns = $this->toIndexed($row, true);
	}
	else {
		$rowAssociative = $this->toAssociative($row);
	}

	if(!$this->headers) {
		throw new HeadersNotSetException();
	}

	$rowColumns = $this->fillMissing($rowColumns);

	$this->file->fseek(0, SEEK_END);
	$this->file->fputcsv($rowColumns);
	$this->file->fflush();

	$this->file->flock(LOCK_UN);
	return $rowAssociative;
}
public function add ( $ row ) { $ this -> changesMade = true ; $ rowColumns = $ row ; $ rowAssociative = $ row ; $ this -> lock ( ) ; if ( $ this -> isAssoc ( $ row ) ) { if ( ! $ this -> headers ) { $ this -> headers = array_keys ( $ row ) ; $ this -> file -> fputcsv ( $ this -> headers ) ; } $ rowColumns = $ this -> toIndexed ( $ row , true ) ; } else { $ rowAssociative = $ this -> toAssociative ( $ row ) ; } if ( ! $ this -> headers ) { throw new HeadersNotSetException ( ) ; } $ rowColumns = $ this -> fillMissing ( $ rowColumns ) ; $ this -> file -> fseek ( 0 , SEEK_END ) ; $ this -> file -> fputcsv ( $ rowColumns ) ; $ this -> file -> fflush ( ) ; $ this -> file -> flock ( LOCK_UN ) ; return $ rowAssociative ; }
Adds a single row to the CSV file, the values according to associative
array keys matching the currently stored headers. If there are no headers
stored, the headers will take the form of the current associative array's
keys, in the order they exist in the array.

@param array $row Associative array containing key-value pairs. Alternatively
an indexed array can be passed in, which will be converted into an
associative array from the stored headers

@return array Returns the added row in associative form
Adds a single row to the CSV file the values according to associative array keys matching the currently stored headers . If there are no headers stored the headers will take the form of the current associative array s keys in the order they exist in the array .