mll-lab / str_putcsv
The missing `str_putcsv` function for PHP
v1.2.0
2025-07-10 08:54 UTC
Requires
- php: ^7.2 || ^8.0
- thecodingmachine/safe: ^1.3 || ^2 || ^3
Requires (Dev)
- ergebnis/composer-normalize: ^2.13
- phpstan/phpstan: ^1
- phpunit/phpunit: ^2 || ^7 || ^8 || ^9
- thecodingmachine/phpstan-safe-rule: ^1
This package is auto-updated.
Last update: 2025-07-10 09:04:26 UTC
README
The missing str_putcsv
function for PHP
Inverse of the PHP native function str_getcsv
.
Installation
composer require mll-lab/str_putcsv
Usage
<?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);
Result:
string(8) "1,a
2,b
"
Credits
Based on https://github.com/kafene/str_putcsv