public function parse(array &$file2): array
    {
        $i = 0;
        foreach ($file2 as &$line) {
            ++$i;

            // Null byte and carriage return removal. (CR+LF)
            $line = str_replace(["\x00", "\r", "\n"], '', $line);

            // Basic sanitization, remove non printable chars.
            $lineTrim = \trim($line);
            $line = \preg_replace($this->stripChars, '', $lineTrim);
            $line_bytes = \strlen($line);

            if ($line_bytes !== \strlen($lineTrim)) {
                $this->errors[] = "There's a not printable character on line " . $i . ": " . $lineTrim;
            }

            if ($line_bytes < 2) {
                continue;
            }

            switch (\substr($line, 0, 3)) {
                case "UNA":
                    if (!$this->unaChecked) {
                        $this->analyseUNA(\substr($line, 4, 6));
                    }
                    break;
                case "UNB":
                    $line = $this->splitSegment($line);
                    if (!$this->unbChecked) {
                        $this->analyseUNB($line[1]);
                    }
                    $this->parsedfile[] = $line;
                    break;
                case "UNH":
                    $line = $this->splitSegment($line);
                    $this->analyseUNH($line);
                    $this->parsedfile[] = $line;
                    break;
                default:
                    $line = $this->splitSegment($line);
                    $this->parsedfile[] = $line;
                    break;
            }
        }

        return $this->parsedfile;
    }
public function parse(array &$file2): array
    {
        $i = 0;
        foreach ($file2 as &$line) {
            ++$i;

            // Null byte and carriage return removal. (CR+LF)
            $line = str_replace(["\x00", "\r", "\n"], '', $line);

            // Basic sanitization, remove non printable chars.
            $lineTrim = \trim($line);
            $line = \preg_replace($this->stripChars, '', $lineTrim);
            $line_bytes = \strlen($line);

            if ($line_bytes !== \strlen($lineTrim)) {
                $this->errors[] = "There's a not printable character on line " . $i . ": " . $lineTrim;
            }

            if ($line_bytes < 2) {
                continue;
            }

            switch (\substr($line, 0, 3)) {
                case "UNA":
                    if (!$this->unaChecked) {
                        $this->analyseUNA(\substr($line, 4, 6));
                    }
                    break;
                case "UNB":
                    $line = $this->splitSegment($line);
                    if (!$this->unbChecked) {
                        $this->analyseUNB($line[1]);
                    }
                    $this->parsedfile[] = $line;
                    break;
                case "UNH":
                    $line = $this->splitSegment($line);
                    $this->analyseUNH($line);
                    $this->parsedfile[] = $line;
                    break;
                default:
                    $line = $this->splitSegment($line);
                    $this->parsedfile[] = $line;
                    break;
            }
        }

        return $this->parsedfile;
    }
public function parse ( array & $ file2 ) : array { $ i = 0 ; foreach ( $ file2 as & $ line ) { ++ $ i ; // Null byte and carriage return removal. (CR+LF) $ line = str_replace ( [ "\x00" , "\r" , "\n" ] , '' , $ line ) ; // Basic sanitization, remove non printable chars. $ lineTrim = \ trim ( $ line ) ; $ line = \ preg_replace ( $ this -> stripChars , '' , $ lineTrim ) ; $ line_bytes = \ strlen ( $ line ) ; if ( $ line_bytes !== \ strlen ( $ lineTrim ) ) { $ this -> errors [ ] = "There's a not printable character on line " . $ i . ": " . $ lineTrim ; } if ( $ line_bytes < 2 ) { continue ; } switch ( \ substr ( $ line , 0 , 3 ) ) { case "UNA" : if ( ! $ this -> unaChecked ) { $ this -> analyseUNA ( \ substr ( $ line , 4 , 6 ) ) ; } break ; case "UNB" : $ line = $ this -> splitSegment ( $ line ) ; if ( ! $ this -> unbChecked ) { $ this -> analyseUNB ( $ line [ 1 ] ) ; } $ this -> parsedfile [ ] = $ line ; break ; case "UNH" : $ line = $ this -> splitSegment ( $ line ) ; $ this -> analyseUNH ( $ line ) ; $ this -> parsedfile [ ] = $ line ; break ; default : $ line = $ this -> splitSegment ( $ line ) ; $ this -> parsedfile [ ] = $ line ; break ; } } return $ this -> parsedfile ; }
Parse edi array

@param array $file2

@return array
Parse edi array