Is there any php libraries or API's that help when dealing with X12 documents in php? Googling around doesn't help much, so looking for people with experience in this field.
Asked
Active
Viewed 2,973 times
3 Answers
5
If you know which Segments and what the meaning in all segments. Then its just about php
$file = file_get_contents('/edi.x12');
$segments = explode(~\n,$file);
foreach($segments as $segment){
$elements = explode('*',$segment);
foreach($elements as $element){
switch($elements[0]){
case 'ISA':
break;
/// And so on
}
}
}
Then you will have an Array consisting all Segments in the file. If your just iterate over the array it is possible to get all Elements for given Segment.
But for creating a x12 Edi file it is a little bit more tricky.
I dont see the point in first convert to Xml.

Jesper Johansson
- 81
- 3
- 5
1
Doing a quick google search, I found a couple of tools that will convert X12 documents to XML. PHP has made a lot of progress in the area of XML parsing.
Is converting to XML first an option?

Scott
- 11,046
- 10
- 51
- 83
-
That is an option actually. Quite a good idea. Preferable to skip on that though, would rather map straight to objects. – lsl Sep 14 '09 at 00:00
-
If you are unable to find what your looking for, i would be interested in working with you to come up with some objects for the community. – Scott Sep 14 '09 at 03:32
-
I believe we went with one other their other implementation options in the end. – lsl Aug 30 '11 at 22:05
-
I'm not able to find any good php based X12 to xml conversion code. I see Java and Python. Does anyone have any current php solutions? – mattmac Oct 25 '11 at 15:02