mll-lab / str_putcsv
PHP 中缺失的 `str_putcsv` 函数
v1.1.0
2023-05-31 13:25 UTC
Requires
- php: ^7.2 || ^8.0
- thecodingmachine/safe: ^1.3 || ^2
Requires (Dev)
- ergebnis/composer-normalize: ^2.13
- phpstan/phpstan: ^1
- phpunit/phpunit: ^2 || ^7 || ^8 || ^9
- thecodingmachine/phpstan-safe-rule: ^1
README
PHP 中缺失的 str_putcsv
函数
PHP 原生函数 str_getcsv
的逆函数。
安装
composer require mll-lab/str_putcsv
用法
<?php declare(strict_types=1); require 'vendor/autoload.php'; $entries = [ [1, 'a'], [2, 'b'], ]; $csv = ''; foreach ($entries as $entry) { $csv .= str_putcsv($entry) . PHP_EOL; } var_dump($csv);
结果
string(8) "1,a
2,b
"