Hello,
I'm trying to use fgets() to get data from an RPG script via a Standard Input stream. I'm familiar w/ using fgets() like this and feof after every line:
$file = fopen("test.txt","r");
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
My issue is, the RPG script is calling my PHP script and is sending me a data stream. Which is fine for 1 line of data but when there are multiple lines of data I'm not sure how to receive it or loop through it to setup my variables?
Here's how I handle one input string:
$cust = fgets(STDIN);
STDIN is the input I'm receiving. Would something like this work w/o a loop :
$cust = fgets(STDIN, 6);
$bizname = fgets(STDIN, 30);
$buildname = fgets(STDIN, 30);
$street = fgets(STDIN, 30);
$street2 = fgets(STDIN, 30);
$politicalDivision2 = fgets(STDIN, 17);
$politicalDivision1 = fgets(STDIN, 2);
$zip = fgets(STDIN, 5);
$ziplow = fgets(STDIN, 4);
$country = fgets(STDIN, 2);
where I include the length of the string or do I need to create some type of loop and add the data to an array? If so, how would I create a loop w/ only fgets? foreach, while?? I've kind of hit a road block.
Thanks in advance,
j