Read from file
Posted: Fri Jun 04, 2010 10:07 am
Hello all, This is my first time here and hope to get settled in for a long run. I'm also really just playing with PHP for the first time in a long time. My PHP is weak as you'll see.
Anyway, I have this strange issue that I hope to find help for.
I'm creating a script and I need to read and parse out a text file. The process here is this:
I do and HTML post to a vendors website (I know, HTML post isn't favorable but I'm told it's all the vendor has available) and get back a result that contains (in test mode) 3 sets of UPS tracking numbers, rates and such. No. I'm not getting this info from UPS. The vendor is actually United Stationers. All that I have working and the "Success/Fail" result is being stored in a temporary text file. This is where I'm having a problem. I know need to read that text file. Here's the contents of that file:
SUCCESS<BR><PRE>1999-11-23327
1 ~UPSS~1Z2Z3Z4Z5Z6Z7Z8Z9Z~DF~19991122~UPSN~A ~999999001~999999001~003~03XXXFF ~1070990 ~
2 ~00002.93~000.89~00000.00~00000.00~
3 ~000.96~0000003.82~
1 ~UPSS~1ZZ2ZZ3ZZ4ZZ5ZZ6ZZ~DF~19991122~UPSN~A ~999999001~999999001~004~04YYYQY ~1070991 ~
2 ~00003.07~000.89~00000.00~00000.00~
3 ~002.66~0000003.96~
1 ~UPSS~1ZZZ2ZZZ3ZZZ4ZZZ5Z~DF~19991122~UPSN~A ~999999001~999999001~005~05ZZZ4C ~1070992 ~
2 ~00003.07~000.89C00000.00~00000.00~
3 ~002.92~0000003.96~
EOF0000009 </PRE>
I've tried just about every function I can find and none seem to be able to handle the data.
I'm currently trying this without success.
$file = fopen("temp1.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
{
echo fgets($file). "<br />";
// var_dump($file);
}
fclose($file);
but I've also tried using file_get_contents without success.
Any pointers would be greatly appreciated.
Bill
Anyway, I have this strange issue that I hope to find help for.
I'm creating a script and I need to read and parse out a text file. The process here is this:
I do and HTML post to a vendors website (I know, HTML post isn't favorable but I'm told it's all the vendor has available) and get back a result that contains (in test mode) 3 sets of UPS tracking numbers, rates and such. No. I'm not getting this info from UPS. The vendor is actually United Stationers. All that I have working and the "Success/Fail" result is being stored in a temporary text file. This is where I'm having a problem. I know need to read that text file. Here's the contents of that file:
SUCCESS<BR><PRE>1999-11-23327
1 ~UPSS~1Z2Z3Z4Z5Z6Z7Z8Z9Z~DF~19991122~UPSN~A ~999999001~999999001~003~03XXXFF ~1070990 ~
2 ~00002.93~000.89~00000.00~00000.00~
3 ~000.96~0000003.82~
1 ~UPSS~1ZZ2ZZ3ZZ4ZZ5ZZ6ZZ~DF~19991122~UPSN~A ~999999001~999999001~004~04YYYQY ~1070991 ~
2 ~00003.07~000.89~00000.00~00000.00~
3 ~002.66~0000003.96~
1 ~UPSS~1ZZZ2ZZZ3ZZZ4ZZZ5Z~DF~19991122~UPSN~A ~999999001~999999001~005~05ZZZ4C ~1070992 ~
2 ~00003.07~000.89C00000.00~00000.00~
3 ~002.92~0000003.96~
EOF0000009 </PRE>
I've tried just about every function I can find and none seem to be able to handle the data.
I'm currently trying this without success.
$file = fopen("temp1.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
{
echo fgets($file). "<br />";
// var_dump($file);
}
fclose($file);
but I've also tried using file_get_contents without success.
Any pointers would be greatly appreciated.
Bill