承接 albinvar/php-csv-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

albinvar/php-csv-generator

最新稳定版本:v2.1.0

Composer 安装命令:

composer require albinvar/php-csv-generator

包简介

The Termux Webzone CLI App.

README 文档

README

Table of Contents

Introduction

A simple php library used to generate php array to csv, json and csv to php array and json.

Installation

composer require albinvar/php-csv-generator

Attach the library to your php code.

<?php

use PhpCsv\Generator;

require_once("./vendor/autoload.php");

$obj = new Generator();

Manual installation

  • Download the script from here.
  • Add the script to your php code.
<?php

require_once "Generator.php";

Updation

composer update albinvar/php-csv-generator

Features

  • Convert CSV to php array
  • Convert array to CSV format
  • Convert array & CSV to json
  • Import JSON and Convert to array.
  • Export JSON format and save or stream json file
  • Export CSV file & save to preferred location
  • Export CSV file & Stream to browser

Array to CSV

You can convert an array into a csv file using the following example.

<?php

use PhpCsv\Generator;

require_once("./vendor/autoload.php");

$columns = ['Name', 'Age'];
$array = [ 
	['John', 28],
	['Johana', 23],
	['Adam', 32],
];

$object = new Generator();
$object->setArray($array, $columns);
$object->makeCsv();
$object->getCsv(); //(Optional) Get CSV as a string.
$object->exportCsv('data.csv', true);

$object->exportCsv('data.csv', true); The first argument excepts the filenams and 2nd argument excepts the download type which expects a boolean format.

CSV to Array

You can convert a csv file to an array using the following example.

<?php

use PhpCsv\Generator;

require_once("./vendor/autoload.php");

$object = new Generator();
$object->importCsv('data.csv');
$array = $object->getArray();

var_dump($array);

JSON to Array

You can convert a JSON file to an array using the following example.

<?php

use PhpCsv\Generator;

require_once("./vendor/autoload.php");

$object = new Generator();
$object->importJson('data.json');
$array = $object->getArray();

var_dump($array);

Export to JSON format

You can export to JSON from both CSV or Array The first argument expects the filename and 2nd argument excpects the download type which should be in a boolean format.

// returns json string.
echo $object->exportJson();

// creates json file and download to browser.
$object->exportJson('data.json', true);

// creates json file and saves it to specific location.
$object->exportJson('data.json', false);

Contributing

Pull requests are always welcome...

License

MIT. See LICENSE for more details.

统计信息

  • 总下载量: 1.52k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固