fork download
  1. <?php
  2.  
  3. $hi = fopen('php://stdin', "r");
  4. $ho = fopen('php://stdout', "w");
  5.  
  6. while (true) {
  7. fscanf($hi, "%d", $n);
  8. if ($n == 42) break;
  9. fwrite($ho, sprintf("%d\n", $n));
  10. }
  11.  
  12. fclose($ho);
  13. fclose($hi);
Success #stdin #stdout 0.04s 25840KB
stdin
1
2
10
42
11
stdout
1
2
10