当前位置: 首页>>代码示例>>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;未经允许,请勿转载。