当前位置: 首页>>代码示例>>PHP>>正文


PHP parseCSV::encoding方法代码示例

本文整理汇总了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());
 }
开发者ID:geminorum,项目名称:gmember,代码行数:20,代码来源:import.class.php

示例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];
}
开发者ID:dipeira,项目名称:espa-payments,代码行数:60,代码来源:functions.php

示例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);
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:40,代码来源:ImportController.php

示例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'));
         }
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:67,代码来源:jlextdfbnetplayerimport.php


注:本文中的parseCSV::encoding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。