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


PHP Writer::createFromString方法代碼示例

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


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

示例1: createCsv

 private function createCsv($inquiryList)
 {
     $writer = Writer::createFromString("");
     $writer->setNewline("\r\n");
     foreach ($inquiryList as $inquiry) {
         /** @var Inquiry $inquiry */
         $writer->insertOne([$inquiry->getId(), $inquiry->getName(), $inquiry->getEmail()]);
     }
     return (string) $writer;
 }
開發者ID:iakio,項目名稱:classic-symfony,代碼行數:10,代碼來源:AdminInquiryListController.php

示例2: generate

 /**
  * Generates a CSV string from given array data
  *
  * @param array $data
  *
  * @throws \RuntimeException
  *
  * @return string
  */
 public function generate(array $data)
 {
     $writer = Writer::createFromString('');
     $writer->setDelimiter($this->delimiter);
     $writer->setEnclosure($this->enclosure);
     if (!is_array($data[0])) {
         $data = [$data];
     }
     $writer->insertAll($data);
     return $writer->__toString();
 }
開發者ID:mjaschen,項目名稱:collmex,代碼行數:20,代碼來源:LeagueCsvGenerator.php

示例3: build

 public function build($keyword)
 {
     $inquiryList = $this->inquiryRepository->findAllByKeyword($keyword);
     /** @var Writer $writer */
     $writer = Writer::createFromString("");
     $writer->setNewline("\r\n");
     foreach ($inquiryList as $inquiry) {
         $writer->insertOne([$inquiry->getId(), $inquiry->getName(), $inquiry->getEmail()]);
     }
     return mb_convert_encoding((string) $writer, $this->encoding, 'UTF-8');
 }
開發者ID:iakio,項目名稱:classic-symfony,代碼行數:11,代碼來源:InquiryCsvBuilder.php

示例4: result

 /**
  * @inheritdoc
  */
 public function result(AnalysisResult $result)
 {
     $writer = Writer::createFromString('');
     $writer->insertOne(['File', 'Line', 'Tool', 'Type', 'Message']);
     foreach ($result->toArray() as $fileName => $lines) {
         foreach ($lines as $lineNumber => $issues) {
             foreach ($issues as $issue) {
                 $writer->insertOne([$fileName, $lineNumber, $issue['tool'], $issue['type'], trim($issue['message'])]);
             }
         }
     }
     $csv = ltrim($writer->__toString());
     $this->cli->out($csv);
 }
開發者ID:ricardorsierra,項目名稱:php-hound,代碼行數:17,代碼來源:CsvOutput.php

示例5:

use League\Csv\Writer;
use League\Csv\Reader;
require '../vendor/autoload.php';
//we are creating a CSV from a raw string
$rawCsv = <<<EOF
Melodie;6;F;2011
Melody;7;F;2011
Melvil;13;M;2011
Melvin;9;M;2011
Menahem;6;M;2011
Mendel;7;M;2011
Meriem;8;F;2011
Merlin;8;M;2011
Meryam;7;F;2011
EOF;
$writer = Writer::createFromString($rawCsv);
//because we raw string delimiter is ";"
//the string delimiter MUST also be ";"
$writer->setDelimiter(';');
//we are creating a CSV from a raw string
$rawCsv2Merge = <<<EOF
Ben,7,M,2007
Benjamin,78,M,2007
Benoît,17,M,2007
Berenice,19,F,2007
Bertille,9,F,2007
Bianca,18,F,2007
Bilal,26,M,2007
Bilel,7,M,2007
EOF;
$csv2merge = Reader::createFromString($rawCsv2Merge);
開發者ID:arvenil,項目名稱:csv,代碼行數:31,代碼來源:merge.php


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