PHP code example of cyberwizzard / mt940

1. Go to this page and download the library: Download cyberwizzard/mt940 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/ */

    

cyberwizzard / mt940 example snippets




use Jejik\MT940\Reader;

$reader = new Reader();

// Load the Rabobank CSV parser
$reader->addParser( 'RabobankCSV', 'cyberwizzard\MT940\Parser\RabobankCSV' );
// Append the list of default bank parsers (optional)
$reader->addParsers( $reader->getDefaultParsers() );
// Load the Ing parser from this repository to replace the one from jejik/MT940
$reader->addParser( 'Ing', 'cyberwizzard\MT940\Parser\Ing' );

$statements = $reader->getStatements(file_get_contents('mt940.txt'));

foreach ($statements as $statement) {
    echo $statement->getOpeningBalance()->getAmount() . "\n";

    foreach ($statement->getTransactions() as $transaction) {
        echo $transaction->getAmount() . "\n";
    }

    echo $statement->getClosingBalance()->getAmount() . "\n";
}