Overview

Namespaces

  • Kotchasan
    • Cache
    • Database
    • Http
    • Log
    • Orm
  • None
  • PHP
  • Psr
    • Cache
    • Http
      • Message
    • Log

Classes

  • Accordion
  • ApiController
  • ArrayTool
  • CKEditor
  • Collection
  • Config
  • Controller
  • Country
  • Csv
  • Curl
  • Currency
  • Database
  • DataTable
  • Date
  • DOMNode
  • DOMParser
  • Email
  • File
  • Files
  • Form
  • Grid
  • Html
  • Htmldoc
  • HtmlTable
  • Image
  • InputItem
  • Inputs
  • KBase
  • Language
  • ListItem
  • Login
  • Menu
  • Mime
  • Model
  • Number
  • ObjectTool
  • Password
  • Pdf
  • Province
  • Router
  • Session
  • Singleton
  • Tab
  • TableRow
  • Template
  • Text
  • Validator
  • View

Exceptions

  • ApiException
  • InputItemException
  • Overview
  • Namespace
  • Class
  • Tree

Class Csv

CSV function.

Namespace: Kotchasan
Author: Goragod Wiriya admin@goragod.com
Since: 1.0
Located at Kotchasan/Csv.php
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

Exception
ถ้า Header ของไฟล์ CSV ไม่ถูกต้อง
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
Kotchasan API documentation generated by ApiGen