Methods summary
public static
array
|
#
import( string $csv, array $columns, array $keys = array(), string $charset = 'Windows-874', integer $skip = 1 )
ฟังก์ชั่นนำเข้าข้อมูล CSV
คืนค่าข้อมูลที่อ่านได้เป็นแอเรย์.
ฟังก์ชั่นนำเข้าข้อมูล CSV
คืนค่าข้อมูลที่อ่านได้เป็นแอเรย์.
Parameters
- $csv
- ชื่อไฟล์รวมพาธ
- $columns
- ข้อมูลคอลัมน์ array('column1' => 'data type', 'column2' => 'data type', ....)
- $keys
- ชื่อคอลัมน์สำหรับตรวจข้อมูลซ้ำ คอลัมน์นี้ต้องไม่เป็นค่าว่าง
- $charset
- รหัสภาษาของไฟล์ ค่าเริ่มต้นคือ Windows-874 (ภาษาไทย)
- $skip
- จำนวนแถวของ header ที่ข้ามการอ่านข้อมูล ค่าเริ่มต้นคือ 1
Returns
array
|
public static
|
#
read( string $file, callable $onRow, integer $skip = 1 )
อ่านไฟล์ CSV ทีละแถวส่งไปยังฟังก์ชั่น $onRow.
อ่านไฟล์ CSV ทีละแถวส่งไปยังฟังก์ชั่น $onRow.
Parameters
- $file
- ชื่อไฟล์รวมพาธ
- $onRow
- ฟังก์ชั่นรับค่าแต่ละแถว มีพารามิเตอร์คือ $data
- $skip
- จำนวนแถวของ header ที่ข้ามการอ่านข้อมูล ค่าเริ่มต้นคือ 1
|
public static
boolean
|
#
send( string $file, array $header, array $datas, string $charset = 'Windows-874' )
สร้างไฟล์ CSV สำหรับดาวน์โหลด
คืนค่า true.
สร้างไฟล์ CSV สำหรับดาวน์โหลด
คืนค่า true.
Parameters
- $file
- ชื่อไฟล์ ไม่ต้องมีนามสกุล
- $header
- ส่วนหัวของข้อมูล
- $datas
- ข้อมูล
- $charset
- ภาษาของ CSV ค่าเริ่มต้นคือ Windows-874 (ภาษาไทย)
Returns
boolean
|