fork(2119) 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.01s 20568KB
stdin
1
2
10
42
11
stdout
1
2
10