public function readGroups(string $before, string $start, string $end, string $after)
    {
        // init
        $groups = [];
        $group = [];
        $position = 'before_search';

        foreach ($this->parsedfile as $edi_row) {
            // search before group segment
            if ($position == 'before_search' && $edi_row[0] == $before) {
                $position = 'before_is';
                continue;
            }

            if ($position == 'before_search') {
                continue;
            }

            if ($position == 'before_is' && $edi_row[0] == $before) {
                continue;
            }

            // after before search start
            if ($position == 'before_is' && $edi_row[0] == $start) {
                $position = 'group_is';
                $group[] = $edi_row;
                continue;
            }

            // if after before segment no start segment, search again before segment
            if ($position == 'before_is') {
                $position = 'before_search';
                continue;
            }

            // get group element
            if ($position == 'group_is' && $edi_row[0] != $end) {
                $group[] = $edi_row;
                continue;
            }

            // found end of group
            if ($position == 'group_is' && $edi_row[0] == $end) {
                $position = 'group_finish';
                $group[] = $edi_row;
                $groups[] = $group;
                $group = [];
                continue;
            }

            // next group start
            if ($position == 'group_finish' && $edi_row[0] == $start) {
                $group[] = $edi_row;
                $position = 'group_is';
                continue;
            }

            // finish
            if ($position == 'group_finish' && $edi_row[0] == $after) {
                break;
            }

            $this->errors[] = 'Reading group ' . $before . '/' . $start . '/' . $end . '/' . $after
                              . '. Error on position: ' . $position;

            return false;
        }

        return $groups;
    }
public function readGroups(string $before, string $start, string $end, string $after)
    {
        // init
        $groups = [];
        $group = [];
        $position = 'before_search';

        foreach ($this->parsedfile as $edi_row) {
            // search before group segment
            if ($position == 'before_search' && $edi_row[0] == $before) {
                $position = 'before_is';
                continue;
            }

            if ($position == 'before_search') {
                continue;
            }

            if ($position == 'before_is' && $edi_row[0] == $before) {
                continue;
            }

            // after before search start
            if ($position == 'before_is' && $edi_row[0] == $start) {
                $position = 'group_is';
                $group[] = $edi_row;
                continue;
            }

            // if after before segment no start segment, search again before segment
            if ($position == 'before_is') {
                $position = 'before_search';
                continue;
            }

            // get group element
            if ($position == 'group_is' && $edi_row[0] != $end) {
                $group[] = $edi_row;
                continue;
            }

            // found end of group
            if ($position == 'group_is' && $edi_row[0] == $end) {
                $position = 'group_finish';
                $group[] = $edi_row;
                $groups[] = $group;
                $group = [];
                continue;
            }

            // next group start
            if ($position == 'group_finish' && $edi_row[0] == $start) {
                $group[] = $edi_row;
                $position = 'group_is';
                continue;
            }

            // finish
            if ($position == 'group_finish' && $edi_row[0] == $after) {
                break;
            }

            $this->errors[] = 'Reading group ' . $before . '/' . $start . '/' . $end . '/' . $after
                              . '. Error on position: ' . $position;

            return false;
        }

        return $groups;
    }
public function readGroups ( string $ before , string $ start , string $ end , string $ after ) { // init $ groups = [ ] ; $ group = [ ] ; $ position = 'before_search' ; foreach ( $ this -> parsedfile as $ edi_row ) { // search before group segment if ( $ position == 'before_search' && $ edi_row [ 0 ] == $ before ) { $ position = 'before_is' ; continue ; } if ( $ position == 'before_search' ) { continue ; } if ( $ position == 'before_is' && $ edi_row [ 0 ] == $ before ) { continue ; } // after before search start if ( $ position == 'before_is' && $ edi_row [ 0 ] == $ start ) { $ position = 'group_is' ; $ group [ ] = $ edi_row ; continue ; } // if after before segment no start segment, search again before segment if ( $ position == 'before_is' ) { $ position = 'before_search' ; continue ; } // get group element if ( $ position == 'group_is' && $ edi_row [ 0 ] != $ end ) { $ group [ ] = $ edi_row ; continue ; } // found end of group if ( $ position == 'group_is' && $ edi_row [ 0 ] == $ end ) { $ position = 'group_finish' ; $ group [ ] = $ edi_row ; $ groups [ ] = $ group ; $ group = [ ] ; continue ; } // next group start if ( $ position == 'group_finish' && $ edi_row [ 0 ] == $ start ) { $ group [ ] = $ edi_row ; $ position = 'group_is' ; continue ; } // finish if ( $ position == 'group_finish' && $ edi_row [ 0 ] == $ after ) { break ; } $ this -> errors [ ] = 'Reading group ' . $ before . '/' . $ start . '/' . $ end . '/' . $ after . '. Error on position: ' . $ position ; return false ; } return $ groups ; }
Get groups from message.

@param string $before segment before groups
@param string $start  first segment of group
@param string $end    last segment of group
@param string $after  segment after groups

@return false|array
Get groups from message .