Overview

Namespaces

  • Sleepy
  • Module
    • Authentication
    • CSV
    • DB
    • FormBuilder
    • FSDB
    • IP2Country
    • Mailer
    • MobiDetect
    • Navigation
    • StaticCache
  • PHP

Classes

  • Document
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Class Document

Creates a Comma Separated Value file.

Usage

// loads a existing CSV file
  $c = new \Module\CSV\Document('presidents.csv');

  $c->add(array(
    'George',
    'Washington'
  ));

  $c->save();

Changelog

Version 1.8

  • Added namespacing
  • Renamed remove method to delete
  • Added a search method

Version 1.6

  • Updated documentation

Version 1.5

  • check if we can remove the header before doing it... teamsite issue.
  • suppress flock warnings... teamsite issue
Namespace: Module\CSV
License: http://opensource.org/licenses/MIT
Author: Jaime A. Rodriguez hi.i.am.jaime@gmail.com
Version: 1.8
Date: August 13, 2014
Located at class.csv.php
Methods summary
public
# __construct( string $filename = '' )

Constructor

Constructor

Parameters

$filename
(optional) if set, loads the file
public boolean
# load( string $filename = '' )

Loads an existing CSV file into $this->data

Loads an existing CSV file into $this->data

Parameters

$filename

(optional) Name of file. If it is not set, then it uses $this->filename instead.

Returns

boolean
Returns true if successful.
public boolean
# save( string $filename = '' )

Saves the CSV file.

Saves the CSV file.

Parameters

$filename

(optional) Name of file. If it is not set, then it uses $this->filename instead.

Returns

boolean
Returns true if successful.
public boolean
# add( mixed $array )

Adds a new line to the CSV file

Adds a new line to the CSV file

Parameters

$array
An array of values.

Returns

boolean
Returns true if successful.
public boolean
# delete( integer $id )

Deletes a line from the CSV file

Deletes a line from the CSV file

Parameters

$id
The array key to remove from $this->data.

Returns

boolean
Returns true if successful.
public array
# search( string $string, boolean $partial = false, boolean $caseSensitive = true )

Search through the CSV for a string and return an associative array of array_index => array()

Search through the CSV for a string and return an associative array of array_index => array()

Parameters

$string
The string to search for
$partial
If true, return partial matches
$caseSensitive
If true, search is case sensitive

Returns

array
An array of matching data
public
# show( )

Instead of saving the file, it outputs to default output with headers.

Instead of saving the file, it outputs to default output with headers.

Properties summary
public string $filename

string The filename of the CSV file

string The filename of the CSV file

# ''
public string $delimiter

string Define what character to use as a delimiter

string Define what character to use as a delimiter

# ','
public $data

mixed The data gets stored here while "in utero"

mixed The data gets stored here while "in utero"

#
sleepyMUSTACHE v.0.8 API documentation generated by ApiGen