From 765ffc12c454e161eacdd95debc768334944f8f5 Mon Sep 17 00:00:00 2001 From: sabas Date: Thu, 22 Mar 2018 12:41:34 +0100 Subject: [PATCH] Optionally remove segmentIdx when encoding already parsed EDI --- src/EDI/Encoder.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/EDI/Encoder.php b/src/EDI/Encoder.php index 4f921c70..c61b43de 100644 --- a/src/EDI/Encoder.php +++ b/src/EDI/Encoder.php @@ -52,7 +52,7 @@ public function __construct($array = null, $wrap = true) $this->encode($array, $wrap); } - public function encode($arr, $wrap = true) + public function encode($arr, $wrap = true, $filterKeys = false) { $this->originalArray = $arr; $edistring = ''; @@ -60,6 +60,9 @@ public function encode($arr, $wrap = true) $k = 0; foreach ($arr as $row) { $k++; + if ($filterKeys) { + unset($row['segmentIdx']); + } $row = array_values($row); $edistring .= $this->encodeSegment($row); if (!$wrap && $k < $count) {