How to take multiple standard input in a single line using php command line

Viewed 1660
like Input is:
3
1 2
2 3
4 5

I have to take those input in given style. Here (1 and 2), (2 and 3) and (4 and 5) have to take in one line as a input.

Here is my code snippet.

 <?php
header('Content-Type: text/plain');

$testCase = (int) fgets(STDIN);

while($testCase--) {
    $myPosition = (int) fgets(STDIN);
    $liftPosition = (int) fgets(STDIN);
}

Implementation in C++

int main()
{
   int testcase, myPos, liftPos;

   cin >> testcase;

   while(testcase--)
   {
      cin >> myPos >> liftPos;
   }
}

So, how can implement the C++ code in PHP ?

2 Answers
Related