當前位置: 首頁>>代碼示例>>PHP>>正文


PHP parseCSV::unparse方法代碼示例

本文整理匯總了PHP中parseCSV::unparse方法的典型用法代碼示例。如果您正苦於以下問題:PHP parseCSV::unparse方法的具體用法?PHP parseCSV::unparse怎麽用?PHP parseCSV::unparse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在parseCSV的用法示例。


在下文中一共展示了parseCSV::unparse方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: json_encode

               
            }
            /*if(cellProperties.readOnly) {
              td.style.opacity = 0.7;
            }*/

            if(!value || value === '') {
              td.style.background = '#EEE';
            }
            else {
              td.style.background = '';
            }
          }

          var data = <?php 
echo json_encode($csv->unparse($csv->data, $csv->titles, null, null, null, true));
?>
;

          var container = $("#example1");
          var hand = container.handsontable({
			data: data,
            startRows: data.length,  //<?php 
echo $csv->filelines('../out/test.csv');
?>
,
			startCols: <?php 
echo count($csv->titles);
?>
,
			rowHeaders: true, //turn on 1, 2, 3, ...
開發者ID:jonca44,項目名稱:pdf-mailmerge,代碼行數:30,代碼來源:index.php

示例2: createDBDataSource

 private function createDBDataSource($filename, $options, $subdir, $file_path)
 {
     global $session, $sql;
     $query = "INSERT INTO datasources (created_at, updated_at, user_id, name, data_path, file_name, `headers`, `lines`)\n\t\t\t\t  VALUES(?, NOW(), ?, ?, ?, ?, ?, ?)";
     $stmt = $sql->link->prepare($query);
     if (!$stmt) {
         die('Invalid query: ' . $sql->link->error);
     } else {
         $csv = new parseCSV();
         $realUserPath = realpath($file_path);
         if (filesize($realUserPath) > 0) {
             $csv->parse($realUserPath, 0, 10000);
             // At max 10000 lines.
             $csvDataRows = $csv->unparse($csv->data, $csv->titles, null, null, null, true);
         } else {
             $csvDataRows = array(array(""));
         }
         $lines = count($csvDataRows) - 1;
         $headers = json_encode($csv->titles);
         $subdirSQL = $options['upload_url'] . $subdir;
         $time = getCurrentDateTime();
         $userID = $this->session->get_user_var('id');
         $stmt->bind_param('sissssi', $time, $userID, $filename, $subdirSQL, $filename, $headers, $lines);
         $resultFromExec = $stmt->execute();
         if ($resultFromExec) {
             $affectedRows = $stmt->affected_rows;
         }
         /* free result */
         $stmt->free_result();
         $stmt->close();
     }
     return array("lines" => $lines, "headers" => implode(", ", array_filter($csv->titles)));
 }
開發者ID:jonca44,項目名稱:pdf-mailmerge,代碼行數:33,代碼來源:upload.class.php

示例3: readCSV

 public function readCSV($inData)
 {
     $csvData = array('error' => "File Not Found");
     $noticeID = $inData['notice_id'];
     $user_file_dir = $this->session->get_user_var('file_directory');
     $basePath = "../user_files/" . $user_file_dir . "/datasources/";
     $realBasePath = realpath($basePath);
     $userPath = $basePath . $inData['subdir'] . $inData['file'];
     $realUserPath = realpath($userPath);
     if ($realUserPath === false || strpos($realUserPath, $realBasePath) !== 0) {
         //Is directory Traversal, bad!
         $this->outData['data'] = $csvData;
     } else {
         //Not directory Traversal.
         $csv = new parseCSV();
         if (filesize($realUserPath) > 0) {
             $csv->parse($realUserPath, 0, 10000);
             // At max 10000 lines.
             $csvDataRows = $csv->unparse($csv->data, $csv->titles, null, null, null, true);
         } else {
             $csvDataRows = array(array(""));
         }
         $csvData = array("csv_data" => $csvDataRows, "header_count" => count($csv->titles), "headers" => $csv->titles, "row_count" => count($csvDataRows), "csv_errors" => $csv->error_info);
         $this->outData['data'] = $csvData;
     }
     echo json_encode($csvData);
 }
開發者ID:jonca44,項目名稱:pdf-mailmerge,代碼行數:27,代碼來源:dataServer.php


注:本文中的parseCSV::unparse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。