First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
46
sites/all/modules/civicrm/Civi/CiUtil/CsvPrinter.php
Normal file
46
sites/all/modules/civicrm/Civi/CiUtil/CsvPrinter.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
namespace Civi\CiUtil;
|
||||
|
||||
/**
|
||||
* Class CsvPrinter
|
||||
*
|
||||
* @package Civi\CiUtil
|
||||
*/
|
||||
class CsvPrinter {
|
||||
var $file;
|
||||
var $headers;
|
||||
var $hasHeader = FALSE;
|
||||
|
||||
/**
|
||||
* @param $file
|
||||
* @param $headers
|
||||
*/
|
||||
public function __construct($file, $headers) {
|
||||
$this->file = fopen($file, "w");
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
public function printHeader() {
|
||||
if ($this->hasHeader) {
|
||||
return;
|
||||
}
|
||||
|
||||
$headers = array_values($this->headers);
|
||||
array_unshift($headers, 'TEST NAME');
|
||||
fputcsv($this->file, $headers);
|
||||
|
||||
$this->hasHeader = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $test
|
||||
* @param $values
|
||||
*/
|
||||
public function printRow($test, $values) {
|
||||
$this->printHeader();
|
||||
$row = $values;
|
||||
array_unshift($row, $test);
|
||||
fputcsv($this->file, $row);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue