PHP code example of radnan / rdn-csv

1. Go to this page and download the library: Download radnan/rdn-csv library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

radnan / rdn-csv example snippets



   return array(
       'modules' => array(
           'RdnCsv',
           // ...
       ),
   );
   ~~~

## How to use

The module comes with two plugins - `CsvExport()` and `CsvImport()`.

### `CsvExport()`

Export data into a downloadable CSV file using this plugin.

~~~php
// inside a controller action

$header = array(
	'Year',
	'Make',
	'Model',
	'Description',
	'Price',
);
$records = array(
	array(
		'1997',
		'Ford',
		'E350',
		'ac, abs, moon',
		'3000.00',
	),
);

return $this->CsvExport('foo.csv', $header, $records);
~~~

The plugin will return a response object which you can then return from your controller action.

[Read more documentation on `CsvExport()`](docs/00-csv-export.md)

### `CsvImport()`

Import data from a CSV file using this plugin.

~~~php
// inside a controller action

$csv = $this->CsvImport('/path/to/foo.csv');

foreach ($csv as $row)
{
	var_dump($row);
	// array(
	//     'Year' => '1997',
	//     'Make' => 'Ford',
	//     'Model' => 'E350',
	//     'Description' => 'ac, abs, moon',
	//     'Price' => '3000.00',
	// )