本文整理汇总了PHP中parseCSV::encoding方法的典型用法代码示例。如果您正苦于以下问题:PHP parseCSV::encoding方法的具体用法?PHP parseCSV::encoding怎么用?PHP parseCSV::encoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parseCSV
的用法示例。
在下文中一共展示了parseCSV::encoding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCSV
public static function getCSV($file_path, $limit = false, $offset = false)
{
if (file_exists($file_path) && is_readable($file_path)) {
if (!class_exists('parseCSV')) {
require_once GMEMBER_DIR . '/assets/libs/parsecsv-for-php/parsecsv.lib.php';
}
$csv = new parseCSV();
$csv->encoding('UTF-16', 'UTF-8');
if ($offset) {
$csv->offset = $offset;
}
if ($limit) {
$csv->limit = $limit;
}
$csv->auto($file_path);
return array('titles' => $csv->titles, 'data' => $csv->data);
}
return false;
return array('titles' => array(), 'data' => array());
}
示例2: parseFind
function parseFind($csvFile, $afm, $surname)
{
// init vars
$empOffset = 5;
$anadrData = [];
// parse csv & find employee
$csv = new parseCSV();
$csv->encoding('iso8859-7', 'UTF-8');
$csv->delimiter = ";";
$csv->heading = false;
// find employee T.M.
$csv->offset = $empOffset;
$condition = '8 is ' . $afm . ' AND 1 contains ' . grstrtoupper($surname);
$csv->conditions = $condition;
$csv->parse($csvFile);
$parsed = $csv->data;
// enhanced check of surname (instead of 'contains' in fullname)
if ($parsed) {
$tmp = explode(' ', $parsed[0][1]);
$fileSurname = $tmp[0];
if (strcmp(grstrtoupper($surname), $fileSurname) != 0) {
return ['parsed' => [], 'month' => []];
}
}
// find month
$csv->offset = 1;
$csv->conditions = '19 contains ΜΙΣΘΟΔΟΣΙΑ';
$csv->parse($csvFile);
//$csv->fields =[19];
$data = $csv->data;
$tmp = explode(' ', $data[0][19]);
$month = $tmp[2] . '_' . $tmp[3];
// find anadromika (if any)
$csv->offset = $empOffset;
$csv->conditions = '';
$csv->parse($csvFile);
$data = $csv->data;
$i = $foundFrom = $foundTo = 0;
foreach ($data as $row) {
if (array_key_exists('8', $row) && $afm == $row[8] && !$foundFrom) {
$foundFrom = $i;
}
if ($foundFrom && !$foundTo && array_key_exists('8', $row)) {
if ($row[8] != '' && $row[8] != $afm) {
$foundTo = $i - 1;
}
}
$i++;
}
$tempData = array_slice($data, $foundFrom, $foundTo - $foundFrom + 1);
foreach ($tempData as $line) {
if ($line[10] == 'ΑΝΑΔΡΟΜΙΚΑ') {
$anadrData = $line;
}
}
if (count($anadrData) > 0) {
array_push($parsed, $anadrData);
}
return ['parsed' => $parsed, 'month' => $month];
}
示例3: importProductsMap
public function importProductsMap()
{
$file = Input::file('file');
if ($file == null) {
Session::flash('error', 'Debe seleccionar un archivo');
return Redirect::to('importar/productos');
}
$name = $file->getRealPath();
require_once app_path() . '/includes/parsecsv.lib.php';
$csv = new parseCSV();
$csv->heading = false;
$csv->encoding('ISO-8859-1', 'UTF-8');
$csv->auto($name);
Session::put('data', $csv->data);
$headers = true;
$hasHeaders = true;
$mapped = array();
$columns = array('', Product::$fieldProductKey, Product::$fieldNotes, Product::$fieldCost);
if (count($csv->data) > 0) {
$headers = $csv->data[0];
for ($i = 0; $i < count($headers); $i++) {
$title = strtolower($headers[$i]);
$mapped[$i] = '';
$map = array('Nombre' => Product::$fieldProductKey, 'Razón Social' => Product::$fieldNotes, 'Nit' => Product::$fieldCost);
foreach ($map as $search => $column) {
foreach (explode("|", $search) as $string) {
if (strpos($title, 'sec') === 0) {
continue;
}
if (strpos($title, $string) !== false) {
$mapped[$i] = $column;
break 2;
}
}
}
}
}
$data = array('data' => $csv->data, 'headers' => $headers, 'hasHeaders' => $hasHeaders, 'columns' => $columns, 'mapped' => $mapped, 'categories' => Category::where('account_id', '=', Auth::user()->account_id)->orderBy('id')->get());
return View::make('importar.import_products_map', $data);
}
示例4: getData
//.........这里部分代码省略.........
$tempmatch->published = 1;
$tempmatch->count_result = 1;
$tempmatch->show_report = 1;
$tempmatch->team1_result = '';
$tempmatch->team2_result = '';
$tempmatch->summary = '';
$tempmatch->match_date = $value['match_date'];
if (isset($value['playground'])) {
if (array_key_exists($value['playground'], $exportplaygroundtemp)) {
$tempmatch->playground_id = $exportplaygroundtemp[$value['playground']];
}
}
$tempmatch->projectteam1_id = $exportteamstemp[$value['heim']];
$tempmatch->projectteam2_id = $exportteamstemp[$value['gast']];
$tempmatch->round_id = $lfdnumberspieltag;
$exportmatch[] = $tempmatch;
if ($lfdnumberpaarung == $anzahlpaarungen) {
$lfdnumberpaarung = 0;
$lfdnumberspieltag++;
}
$lfdnumbermatch++;
$lfdnumberpaarung++;
}
// daten übergeben
$this->_datas['round'] = array_merge($exportround);
$this->_datas['match'] = array_merge($exportmatch);
$this->_datas['team'] = array_merge($exportteams);
$this->_datas['projectteam'] = array_merge($exportprojectteams);
$this->_datas['club'] = array_merge($exportclubs);
$this->_datas['playground'] = array_merge($exportplayground);
/**
* das ganze für den standardimport aufbereiten
*/
$output = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
// open the project
$output .= "<project>\n";
// set the version of JoomLeague
$output .= $this->_addToXml($this->_setJoomLeagueVersion());
// set the project datas
if (isset($this->_datas['project'])) {
$output .= $this->_addToXml($this->_setProjectData($this->_datas['project']));
}
// set league data of project
if (isset($this->_datas['league'])) {
$output .= $this->_addToXml($this->_setLeagueData($this->_datas['league']));
}
// set season data of project
if (isset($this->_datas['season'])) {
$output .= $this->_addToXml($this->_setSeasonData($this->_datas['season']));
}
// set the rounds data
if (isset($this->_datas['round'])) {
$output .= $this->_addToXml($this->_setXMLData($this->_datas['round'], 'Round'));
}
// set the teams data
if (isset($this->_datas['team'])) {
$output .= $this->_addToXml($this->_setXMLData($this->_datas['team'], 'JL_Team'));
}
// set the clubs data
if (isset($this->_datas['club'])) {
$output .= $this->_addToXml($this->_setXMLData($this->_datas['club'], 'Club'));
}
// set the matches data
if (isset($this->_datas['match'])) {
$output .= $this->_addToXml($this->_setXMLData($this->_datas['match'], 'Match'));
}