Kingsquare has developed a MT940 file parser which reads the given file or string, determines the (dutch) bank and applies a parser. The output from the parser is a manageable and easily usable format of PHP objects which can be passed on for further processing.

The parser tries to determine which originating bank it is from via the first few lines of the file and then loads up the engine per bank.
This way the developer has the ability to extend the actual bank-engine quite easily by overruling / defining its own set of rules to determine the bank.

Since most banks adhere to a standard a default can also be used for parsing the files and statements within.

The downloadable package provides several pieces:

  • banking objects
    the actual storage (struct classes) for data retention and easy access.
  • parsers
    per bank a different parser can be utilized and customized as see fit
  • parser unittests
    ofcourse several (simple) unittests are provided to ensure correct parsing

Example usage

Below is a simple example of possible usage scenarios

// include the required classes
// simple function to form an autoloader-like functionality
function includeClass($className, $libPath = null) {
	static $classes = array();
	if (isset($classes[$class])) return;

	$class = ucfirst($class);
	if (is_null($libPath))  {
		$libPath = dirname(__FILE__);
	$explodedClass = explode('_', $class);
	$fistClassPart = array_shift($explodedClass);
	$classFileName = $libPath.implode(DIRECTORY_SEPARATOR, array_reverse($explodedClass)).DIRECTORY_SEPARATOR
	$classes[$class] = is_readable($classFileName);
	if ($classes[$class]) {
		require $classFileName;
	} else {
		trigger_error('Class '.$class.' could not be imported into the scope when looking in '.$classFileName, E_USER_ERROR);


// instantiate the actual parser
// and parse them from a given file, this could be any file or a posted string
$parser = new Mt940_banking_parser();
$tmpFile = '/tmp/TEMPFILE.mta';
$parsedStatements = $parser->parse(file_get_contents($tmpFile));

// instantiate the actual parser
// and parse them from a given file, this could be any file or a posted string
$parser = new Mt940_banking_parser();
$parsedStatementsFromString = $parser->parse($string);

The parsed statements is a simple array containing Statement_Banking objects which each contain possible Transaction_Banking objects Further processing could be something in the lines of:

// continued from above
foreach ($parsedStatements as $statement) {
	$transactions = $statement->getTransactions();
	// walk the transactions and try to find matches
	foreach ($transactions as $transaction) {
		echo $transaction->getAccountName().' made a transaction for the amount of '.$transaction->getPrice();

Ofcourse this too could be extended to include matching the descriptions (or account numbers, amounts etc) to possible customer information. We've included this function in our KMT-product as a closed beta, but please feel free to contact us for further information or other type of feedback.


This program is free software, released under the terms of the GNU General Public License as published by the Free Software Foundation version 2 The project main page can be found at

Download the files here:

Please feel free to send in your updates, improvements and bugfixes.