1. Go to this page and download the library: Download gffuma/verga 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/ */
gffuma / verga example snippets
use Verga\Verga;
/**
* Make the csv importer.
*
*/
$importer = Verga::importer([
/**
* Number of rows to skip.
* Default: 0
*
*/
'skip' => 1,
/**
* String used to parse csv lines.
* Default ';'
*
*/
'delimiter' => ';',
/**
* Columns configuration.
*
*/
'cols' => [
/**
* Configure each column.
*
*/
'email' => [
/**
* Map the csv column at index 1 with the `email` field.
*
*/
'col' => 1,
/**
* When set to true and there is no column index in current csv
* line. The line fail and the error is reported.
* Default: true
*
*/
' */
$lineNumber,
/**
* Original csv line.
*
*/
$line
) {
return strtolower($value);
},
/**
* You can also validate each column value.
*
*/
'validate' => function ($value /*, $data, $row, $lineNumber, $line*/ ) {
if (! filter_var($value, FILTER_VALIDATE_EMAIL)) {
return Verga::error("The email {$value} is invalid!");
}
}
],
/**
* This is a shortcut for:
*
* 'name' => [
* 'col' => 0
* ],
*/
'name' => 0,
/**
* Map column to nested array:
*
*/
'info' => Verga::combine([
'role' => Verga::combine([
'name' => 2,
'level' => [
'col' => 3,
'orter->importFromString($_POST['csv_to_parse']);
// You can also get the lines alredy filtered:
// $result->getValidLines()
// $result->getInvalidLines()
foreach ($result->getLines() as $line) {
// Is the line valid?
$line->isValid();
// Is the line invalid?
$line->isInvalid();
// Is the line imported?
// true when is a valid line the import callback was runned
$line->isImported();
// Line original line number of csv from 0 to N
$line->getLineNumber();
// Original csv line
$line->getLine();
// The row parsed
$line->getRow();
// The parsed data
$line->getParsedData();
// The imported data returned from import callback
$line->getImportedLine();
// The columns errors when line is invalid
$line->getColumnsErrors();
$line->hasColumnsErrors();
// The line error when line is invalid
$line->getLineError();
$line->hasLineError();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.