QUOTE(Gornakle @ Mar 15 2005, 07:32 PM)
Is it always the second line and the sixth element (if you seperate them by *s)? If so, you could use something like (assuming this is for PHP):
CODE
<php
$fileurl = "./somefilename.txt";
$file = file($fileurl);
$file_split = explode('*' , $file[1]);
echo $file_split[5];
?>
(Not tested, but should work). You could also do an expression to find the sixth element in the line starting with "GS", it all depends on how specific you want to get.
I got it to work, since it was so hard for me I thought I would try and post the code that finally broke the hump! i hope someone can use this!
In PHP here is the winning code
echo "This is a number number array of the order 855 receipt";
echo "<br>";
$lines=file("X12.997.20050202.083929.txt");
foreach ($lines as $line_num => $line)//not needed but nice
$line2 = explode( "*",$line);// also called twice but I like it here too
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
sort($lines);
$line2 = explode( "*",$lines[6]);
echo $line2[5];
echo "<br>";
my code, Its a little sloppy but It helped me to see whats going on from a few angles.
The kicker or winner is the sort command. So I will do my best to describe what is happening.
I open a file with $lines=file()
The File command puts everything in the () into an array.
My file is deliminated by * so I needed to find a way to seperate each line by the deliminator. I also needed a way to get to that line of the array since the file was multilined. Here is what the a good portion of the txt file actully looks like when its opened.
ISA*00* *00* *01*043109560T *01*3125533 *050209*1057*U*00401*000000045*0*T*>~
GS*PR*043109560T*3125533*20050209*1057*15*X*004010~
Pattern matched: GS THIS line contains the UNique ID Number I needST*855*000000022~
BAK*00*AE*TEST01*20050201~
N1*ST*JOHN~
N3*1415 34TH~
N4*FARGO*ND*58103~
PO1*1*1*EA*****VN*PXX X879512X~
Using sort it sorted the array or the file alphabetical by the first character of the array element. so by calling or echoing $lines[6] it displayed all of line GS*PR etc..etc.. becuse G was the 6th letter in the overall sort. So then I broke up that line by the deliminator of * with the explode command and now can grab each and every stinking little element. RRRRRRRRRRRRRRRRRRRRRRR
Thanks all stay cool and keep up the coding!