Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jabranr committed Feb 9, 2017
1 parent 8e4ddf5 commit 60ba63c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# CSV Parser (PHP) [![Build Status](https://travis-ci.org/jabranr/csv-parser.svg?branch=master)](https://travis-ci.org/jabranr/csv-parser) [![Latest Stable Version](https://poser.pugx.org/jabranr/csv-parser/v/stable.svg)](https://packagist.org/packages/csv-parser/csv-parser) [![Total Downloads](https://poser.pugx.org/jabranr/csv-parser/downloads.svg)](https://packagist.org/packages/jabranr/csv-parser)
# CSV Parser (PHP) [![Build Status](https://travis-ci.org/jabranr/csv-parser.svg?branch=master)](https://travis-ci.org/jabranr/csv-parser) [![Latest Stable Version](https://poser.pugx.org/jabranr/csv-parser/v/stable.svg)](https://packagist.org/packages/jabranr/csv-parser) [![Total Downloads](https://poser.pugx.org/jabranr/csv-parser/downloads.svg)](https://packagist.org/packages/jabranr/csv-parser)

PHP client to parse CSV data from a path, file, stream, resource or string into indexed or associative arrays.

> Namespaces added in v2.0.2 so make sure you update your code before migrating from an older version.
> Namespaces were added in v2.0.2 so make sure you update your code before migrating from an older version.
# Install
Install using [composer](http://getcomposer.org)
Expand All @@ -12,7 +12,7 @@ Install using [composer](http://getcomposer.org)

{
"require": {
"jabranr/csv-parser": "~2.0.*"
"jabranr/csv-parser": "~2.1.*"
}
}
```
Expand All @@ -33,31 +33,31 @@ $csv = new Jabran\CSV_Parser();
Get data from a string
```php
/* @param: string $str */
$csv->fromString( $str );
$csv->fromString($str);
```

Get data from a stream (Will be deprecated in future)
```php
/* @param: resource $stream (f.e. php://input) */
$csv->fromStream( $stream );
$csv->fromStream($stream);
```

Get data from a resource (Since v2.0.2)
```php
/* @param: resource $resource (f.e. resource created using fopen()) */
$csv->fromResource( $resource );
$csv->fromResource($resource);
```

Get data from a file path (Will be deprecated in future)
```php
/* @param: string $file */
$csv->fromFile( $file );
$csv->fromFile($file);
```

Get data from a path/URL (Since v2.0.2)
```php
/* @param: string $path */
$csv->fromPath( $path );
$csv->fromPath($path);
```

Parse data for output
Expand All @@ -69,7 +69,7 @@ Parse data for output
* @param: boolean $headers (Default: true)
* @return: array
*/
$csv->parse( $headers );
$csv->parse($headers);
```

More useful methods (Since v2.0.2)
Expand All @@ -80,21 +80,21 @@ More useful methods (Since v2.0.2)
* @param array $columns
* @return Jabran\CSV_Parser
*/
$csv->setColumns( $columns );
$csv->setColumns($columns);

/**
* Set rows
* @param array $rows
* @return Jabran\CSV_Parser
*/
$csv->setRows( $rows );
$csv->setRows($rows);

/**
* Set headers
* @param array $headers
* @return Jabran\CSV_Parser
*/
$csv->setHeaders( $headers );
$csv->setHeaders($headers);

/**
* Get columns
Expand Down Expand Up @@ -125,7 +125,7 @@ $csv = new Jabran\CSV_Parser;

$str = 'id,first_name,last_name;1,Jabran,Rafique';

$csv->fromString( $str );
$csv->fromString($str);

// Output with headers:
$csv->parse();
Expand All @@ -137,23 +137,23 @@ Array(
)

// Output without headers:
$csv->parse( false );
$csv->parse(false);

Array(
[0] => array(
[0] => 'id',
[1] => 'first_name',
[2] => 'last_name'
),
),
[1] => array(
[0] => 1,
[1] => 'Jabran',
[2] => 'Rafique'
)
)
)
```

# License
© 2015 MIT License - [Jabran Rafique](http://jabran.me)
© 2015—2017 MIT License - [Jabran Rafique](http://jabran.me)

[![Analytics](https://ga-beacon.appspot.com/UA-50688851-1/csv-parser)](https://github.com/igrigorik/ga-beacon)

0 comments on commit 60ba63c

Please sign in to comment.