-1

I need to read stdin with php. I need to read first line > save it to the variable > print this variable > read second line > save it to same variable (rewrite old content) > print it - read third line > ... > end of inserted text.

example of imput data:

u A
u B
h A > B 1 :h1
u C
h B > C 1 :h2
u D

Can somebody help me?

user3016214
  • 69
  • 1
  • 7

1 Answers1

0

Here is an example how to do this. PHP standard input?

here is http://www.php.net/manual/en/features.commandline.io-streams.php php manual for manipulating i/o streams

If you have any further questions don't hessitate to ask

Community
  • 1
  • 1
  • Thanks links that you posted was very useful. I am already writing my script and I found new problem. Now I am reading STDIN with fgets but problem is, that I need to read one single line even if I copy-paste content to STDIN. example and code here:akela.mendelu.cz/~xmikulka/test.html This script will put all there 3 lines in to variable $line, but I need to put only "1st line" to $line. How to do it? sorry for my bad english – user3016214 Mar 07 '14 at 13:33