Methods summary
public static
array
|
#
import( string $csv, array $columns, array $keys = null, string $charset = 'Windows-874' )
ฟังก์ชั่นนำเข้าข้อมูล CSV
คืนค่าข้อมูลที่อ่านได้เป็นแอเรย์
ฟังก์ชั่นนำเข้าข้อมูล CSV
คืนค่าข้อมูลที่อ่านได้เป็นแอเรย์
Parameters
- $csv
- ชื่อไฟล์รวมพาธ
- $columns
- ข้อมูลคอลัมน์ array('column1' => 'data type', 'column2' => 'data type', ....)
- $keys
- ชื่อคอลัมน์สำหรับตรวจข้อมูลซ้ำ null(default) หมายถึงไม่ตรวจสอบ
- $charset
- รหัสภาษาของไฟล์ ค่าเริ่มต้นคือ Windows-874 (ภาษาไทย)
Returns
array
|
public static
|
#
read( string $file, function $onRow, array $headers = array() )
อ่านไฟล์ CSV ทีละแถวส่งไปยังฟังก์ชั่น $onRow
แถวแรกของข้อมูลคือ Header ต้องระบุเสมอ
อ่านไฟล์ CSV ทีละแถวส่งไปยังฟังก์ชั่น $onRow
แถวแรกของข้อมูลคือ Header ต้องระบุเสมอ
Parameters
- $file
- ชื่อไฟล์รวมพาธ
- $onRow
- ฟังก์ชั่นรับค่าแต่ละแถว function($data){}
- $headers
- แอเรย์เก็บชื่อคอลัมน์สำหรับการทดสอบความถูกต้อง ถ้าไม่ระบุจะไม่ตรวจสอบ
Throws
|
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
|