pradeepucer/web_dev_tools
最新稳定版本:v2.0
Composer 安装命令:
composer require pradeepucer/web_dev_tools
包简介
Various PHP, JS, SQL, CSS and HTML Web Development tools
README 文档
README
Overview
Various PHP, JS, SQL, CSS and HTML Web Development tools
Requirements
- PHP version 5.4 or newer
Installation
Install the package using Composer: composer require devpradeep/web_dev_tools
CSV Reader
This is a simple CSV reader that can read a CSV file and return the data as an array. It also supports mapping the data based on a provided mapper, and allows for offset and limit to control the data read.
Usage
$file_input = 'test.csv'; $csv = new CSV($file_input); try { // Example 1: Read all records $data = $csv->read($file_input, []); print('<pre>'.print_r($data,true).'</pre>'); // Example 2: Read only 10 records $data = $csv->read($file_input, [], 1, 10); print('<pre>'.print_r($data,true).'</pre>'); // Example 3: Read only row number 10 $data = $csv->read($file_input, [], '', '',10); print('<pre>'.print_r($data,true).'</pre>'); // Example 4: Read with mapper $map['id'] = 2; $map['desc'] = 12; $data = $csv->read($file_input, $map, '', '',10); print('<pre>'.print_r($data,true).'</pre>'); $file_output = 'log.csv'; $csv_write = new CSV($file_output); $data[] = ['id' => 1, 'desc' => 'test1,455,5567 , 9900', 'link' => 'http://test1.com']; $data[] = ['id' => 2, 'desc' => 'test2,569697,454', 'link' => 'http://test1.com']; //Simple write //$file = $csv_write->write($file_output, $data); $map = []; $map['ID'] = 'id'; $map['Link'] = 'link'; $map['Description'] = 'desc'; $formatter = array( 'link' => function ( $v ) { $m = $v['link'] . '/test'; return $m; }, ); //$file = $csv_write->write($file_output, $data, $map, $formatter)->file; $csv_write->write($file_output, $data, $map, $formatter)->download(); } catch (Exception $e) { echo "Error: " . $e->getMessage() . "\n"; }
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-04-11