php-edifact / edifact

Tools to process EDI messages in UN/EDIFACT format
GNU Lesser General Public License v3.0
275 stars 88 forks source link

EDI Reader #14

Closed salvisb closed 8 years ago

salvisb commented 9 years ago

What is preferred method for reading multiple segments, for example if I want to get an array of all LIN segments? Should I write my own script for finding needed segments or it is done with EDI Reader?

Thanks!

uldisn commented 9 years ago

Real example from : https://github.com/uldisn/edifactdata/blob/master/commands/ReadTerminalPop3Command.php

        $f = explode(PHP_EOL, $data);
        $EdiReader = new EDI\Reader($f);
        $terminal = $EdiReader->readEdiDataValue('UNB', 2);
        $message_ref_number = $EdiReader->readEdiDataValue('UNH', 1);        
        $prepare_date = $EdiReader->readEdiDataValue('UNB', 4, 0);
        $prepare_time = $EdiReader->readEdiDataValue('UNB', 4, 1);

For general reading use: https://github.com/sabas/edifact/blob/master/src/EDI/Reader.php#L80

Specialised for segments: