PHP code example of fbizi / import-export-files

1. Go to this page and download the library: Download fbizi/import-export-files 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/ */

    

fbizi / import-export-files example snippets

ruby

define("DIR_PATH", "_DIR_./../uploads/");
 use only one of them depends of your needs
use FBIZI\IE\Importers\{ // you can use only one of them depends of your needs
    ImportCsv,
    ImportJson,
    ImportXml
};
use FBIZI\IE\Exporters\{ // you can use only one of them depends of your needs
    ExportCsv,
    ExportJson,
    ExportXml
};

// Import xml file example
$obj = new Importer(
    //new ImportCsv(DIR_PATH . "testes.csv")
    //new ImportJson(DIR_PATH . "testes.json")
    new ImportXml(DIR_PATH . "testes.xml")
);
$data = $obj->importer->import();

foreach ($data['users'] as $user) {
    echo "{$user->fname} {$user->lname}\n"; 
}

// Export xml file example
$data = [
 	[ 'name' => 'John Deor', 'age' => '34', 'role' => 'Developer' ],
 	[ 'name' => 'John Deep', 'age' => '37', 'role' => 'Seller' ],
 	[ 'name' => 'John Walker', 'age' => '37', 'role' => 'Manager' ]
 ];

$obj = new Exporter(
    //new ExportCsv($data, DIR_PATH . "downloads/testes.csv")
    //new ExportJson($data, DIR_PATH . "downloads/testes.json")
    new ExportXml($data, DIR_PATH . "downloads/testes1.xml")
);
$res = $obj->exporter->export();
echo $res;