3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public function resolve(string $description) { $cases = [ 'IBAN+' => 'iban', // = SEPA IBAN Auftraggeber 'BIC+' => 'bic', // = SEPA BIC Auftraggeber 'EREF+' => 'eref', // = SEPA End to End-Referenz 'KREF+' => 'kref', // = Kundenreferenz 'MREF+' => 'mref', // = SEPA Mandatsreferenz 'CRED+' => 'cred', // = SEPA Creditor Identifier 'DEBT+' => 'debt', // = Originator Identifier 'COAM+' => 'coam', // = Zinskompensationsbetrag 'OAMT+' => 'oamt', // = Ursprünglicher Umsatzbetrag 'SVWZ+' => 'svwz', // = SEPA Verwendungszweck 'ABWA+' => 'abwa', // = Abweichender SEPA Auftraggeber 'ABWE+' => 'abwe', // = Abweichender SEPA Empfänger 'BREF+' => 'bref', // = Bankreferenz, Instruction ID 'RREF+' => 'rref', // = Retourenreferenz ]; $pattern = []; foreach ($cases as $case => $attr) { $pat = ''; for ($i = 0; $i < strlen($case) - 1; $i++) { $pat .= $case[$i] . '(?:[\n\s]*)'; } $pat .= '\+'; //$pattern[] = "(?P<$attr>" . preg_quote($case) . ")"; $pattern[] = "(?P<$attr>" . $pat . ")"; } var_dump($pattern); $output = (array) preg_split( "/" . implode('|', $pattern) ."/i", $description, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); var_dump($output); } } $a = new A(); $input = [ 'OLAF JUNGNICKEL SEPA-ÜBERWEISUNG IBAN+ DE8985050300022 1071105 BIC+ OSDDDE81XXX SV WZ+ TH-BESTELLNUM. 11700305 99 DAS TIERHOTEL KREF+ GENO DEF1S0117032007120004000540 1500', 'Telekom Deutschland GmbH SEPA-BASISLASTSCHRIFT SVWZ+ O THR sonstige Zahlung Festne tz Vertragskonto 5613869876 RG 9146384240/16.10.2017 E REF+ Zahlbeleg 372306090158 MREF+ DE000201100200000000 000000006557566 CRED+ DE93Z ZZ00000078611', ], foreach ($input as $in) { $a->resolve($in); }
Output for 7.1.11
Parse error: syntax error, unexpected ',' in /in/et70j on line 48
Process exited with code 255.